import Fastify from 'fastify';
type CreateProject = {
name: string;tenantId: string
};
const app = Fastify({
logger: true
});
const body = {
type: 'object',
required: ['name', 'tenantId'],
additionalProperties: false,
properties: {
name: {
type: 'string',
minLength: 1
},
tenantId: {
type: 'string',
minLength: 1
},
},
}
as
const;
app.post < {
Body: CreateProject
} > ('/projects', {
schema: {
body
}
}, async (req, reply) => {
const {
name,
tenantId
} = req.body;
return reply.code(201).send({
id: crypto.randomUUID(),
name,
tenantId
});
});
app.get('/health', async () => ({
ok: true
}));
await app.listen({
port: 3000,
host: '0.0.0.0'
});