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
28 lines (22 loc) · 677 Bytes
/
Copy pathserver.ts
File metadata and controls
28 lines (22 loc) · 677 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 './loadEnv';
import Fastify from 'fastify';
import type { FastifyInstance } from 'fastify';
import { privateRoutes, publicRoutes } from './routes';
import FastifyView from '@fastify/view';
import * as ejs from 'ejs';
const server: FastifyInstance = Fastify({ logger: true });
// ejs view engine to render templates
server.register(FastifyView, { engine: { ejs } });
// private routes (with clerkPlugin)
server.register(privateRoutes);
// public routes (without clerkPlugin)
server.register(publicRoutes);
const start = async () => {
try {
await server.listen({ port: 3000 });
} catch (err) {
server.log.error(err);
process.exit(1);
}
};
start();