-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
28 lines (24 loc) · 805 Bytes
/
Copy pathserver.ts
File metadata and controls
28 lines (24 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import Koa from 'koa';
import bodyParser from 'koa-bodyparser';
import commentRoutes from './backend/routes/comments';
import authRoutes from './backend/routes/auth';
const app = new Koa();
app.use(bodyParser());
app.use(async (ctx, next) => {
console.log(`Request: ${ctx.method} ${ctx.url}`);
await next();
});
app.use(commentRoutes.routes());
app.use(commentRoutes.allowedMethods());
app.use(authRoutes.routes());
app.use(authRoutes.allowedMethods());
app.listen(3000, () => {
console.log('Server running at http://localhost:3000');
console.log('Registered routes:');
commentRoutes.stack.forEach((route) => {
console.log(`${route.methods.join(', ')} ${route.path}`);
});
authRoutes.stack.forEach((route) => {
console.log(`${route.methods.join(', ')} ${route.path}`);
});
});