forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
27 lines (19 loc) · 709 Bytes
/
Copy pathserver.ts
File metadata and controls
27 lines (19 loc) · 709 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
import type { Application, Request, Response, NextFunction } from 'express';
import { clerkMiddleware } from '@clerk/express';
import * as express from 'express';
import { privateRoutes, publicRoutes } from './routes';
import './loadEnv';
const port = process.env.PORT || 3000;
const app: Application = express();
app.set('view engine', 'ejs');
app.set('views', 'src/views');
app.use(clerkMiddleware());
app.use(publicRoutes);
app.use(privateRoutes);
app.use((err: Error, _req: Request, res: Response, _next: NextFunction) => {
console.error(err.stack);
res.status(401).send('Unauthenticated!');
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});