-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (36 loc) · 1.15 KB
/
Copy pathserver.js
File metadata and controls
37 lines (36 loc) · 1.15 KB
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
29
30
31
32
33
34
35
36
37
import * as dotenv from "dotenv";
dotenv.config();
import Fastify from "fastify";
export const fastify = Fastify({
logger: true,
});
import fastifySwagger from "@fastify/swagger";
import fastifySwaggerUi from "@fastify/swagger-ui";
import { swaggerConfig, swaggerUIConfig } from "./config/swagger.config.js";
import cors from "@fastify/cors";
// postgres
import "./config/sequelize.config.js";
// cors
fastify.register(cors);
// bcrypt
import fastifyBcrypt from "fastify-bcrypt";
fastify.register(fastifyBcrypt, { saltWorkFactor: 12 });
// JWT
import fastifyJwt from "@fastify/jwt";
fastify.register(fastifyJwt, { secret: process.env.SECRET_KEY });
// routes
import userRoutes from "./router/user.router.js";
import authRoutes from "./router/auth.router.js";
// swagger
fastify.register(fastifySwagger, swaggerConfig);
fastify.register(fastifySwaggerUi, swaggerUIConfig);
// routes
fastify.register(userRoutes, { prefix: "/user" });
fastify.register(authRoutes, { prefix: "/auth" });
fastify.listen({ port: process.env.APPLICATION_PORT }, function (err, address) {
if (err) {
fastify.log.error(err);
process.exit(1);
}
fastify.log.info("Server Started");
});