mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-08-14 04:22:54 +02:00
「🏗️」 wip: work in progress, not done yet.
This commit is contained in:
2
Justfile
2
Justfile
@ -9,7 +9,7 @@ user:
|
|||||||
fastify start src/api/user/default.js
|
fastify start src/api/user/default.js
|
||||||
|
|
||||||
apis:
|
apis:
|
||||||
node dev.js
|
node src/dev.js
|
||||||
|
|
||||||
front:
|
front:
|
||||||
vite
|
vite
|
||||||
|
4
dev.js
4
dev.js
@ -1,6 +1,6 @@
|
|||||||
import Fastify from 'fastify';
|
import Fastify from 'fastify';
|
||||||
import authApi from './src/api/auth/default.js';
|
import authApi from './api/auth/default.js';
|
||||||
import userApi from './src/api/user/default.js';
|
import userApi from './api/user/default.js';
|
||||||
|
|
||||||
const loggerOption = {
|
const loggerOption = {
|
||||||
transport: {
|
transport: {
|
||||||
|
@ -122,10 +122,12 @@ export default async function(fastify, options) {
|
|||||||
// POST
|
// POST
|
||||||
fastify.post('/users/:userId', { preHandler: [fastify.authenticateAdmin] }, async (request, reply) => {
|
fastify.post('/users/:userId', { preHandler: [fastify.authenticateAdmin] }, async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
|
const userId = request.params.userId;
|
||||||
|
|
||||||
if (getUserInfo.get(userId)) {
|
if (getUserInfo.get(userId)) {
|
||||||
return reply.code(400).send({ error: "User already exist" });
|
return reply.code(400).send({ error: "User already exist" });
|
||||||
}
|
}
|
||||||
createUser.run(request.params.userId, request.params.userId);
|
createUser.run(userId, userId);
|
||||||
return reply.code(200).send({ msg: "User created sucessfully" });
|
return reply.code(200).send({ msg: "User created sucessfully" });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
fastify.log.error(err);
|
fastify.log.error(err);
|
||||||
|
32
src/dev.js
Normal file
32
src/dev.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import Fastify from 'fastify';
|
||||||
|
import authApi from './api/auth/default.js';
|
||||||
|
import userApi from './api/user/default.js';
|
||||||
|
|
||||||
|
const loggerOption = {
|
||||||
|
transport: {
|
||||||
|
target: 'pino-pretty',
|
||||||
|
options: {
|
||||||
|
colorize: true,
|
||||||
|
translateTime: 'HH:MM:ss',
|
||||||
|
ignore: 'pid,hostname'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
async function start() {
|
||||||
|
const auth = Fastify({
|
||||||
|
logger: loggerOption
|
||||||
|
});
|
||||||
|
auth.register(authApi);
|
||||||
|
await auth.listen({ port: 3001 });
|
||||||
|
console.log('Auth API listening on http://localhost:3001');
|
||||||
|
|
||||||
|
const user = Fastify({
|
||||||
|
logger: loggerOption
|
||||||
|
});
|
||||||
|
user.register(userApi);
|
||||||
|
await user.listen({ port: 3002 });
|
||||||
|
console.log('User data API listening on http://localhost:3002');
|
||||||
|
}
|
||||||
|
|
||||||
|
start().catch(console.error);
|
7
tailwind.config.js
Normal file
7
tailwind.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export default {
|
||||||
|
content: ['./src/front/**/*.{html,js}'],
|
||||||
|
theme: {
|
||||||
|
extend: {},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
Reference in New Issue
Block a user