Initial
This commit is contained in:
28
index.ts
Normal file
28
index.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import argon2 from "argon2";
|
||||
import {guard} from './utilities/guard';
|
||||
import auth from "./endpoints/auth";
|
||||
import user from "./endpoints/user";
|
||||
|
||||
const server = Bun.serve({
|
||||
routes: {
|
||||
"/api/auth/login": {
|
||||
POST: auth.login,
|
||||
},
|
||||
"/api/auth/test": {
|
||||
GET: guard(auth.test, ['ADMIN', 'USERS_OTHER_DELETE'])
|
||||
},
|
||||
"/api/user": {
|
||||
POST: guard(user.create, ['ADMIN', 'USERS_CREATE'])
|
||||
},
|
||||
"/api/user/:id": {
|
||||
GET: guard(user.get, ['ADMIN', 'USERS_OTHERS_READ', 'USERS_SELF_READ'])
|
||||
},
|
||||
},
|
||||
|
||||
// (optional) fallback for unmatched routes:
|
||||
fetch(request: Request): Response {
|
||||
return Response.json({message: "Not found"}, {status: 404});
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`Server running at ${server.url}`);
|
||||
Reference in New Issue
Block a user