You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
876 B
JavaScript
38 lines
876 B
JavaScript
import express from "express";
|
|
import { auth } from "./middlewares/auth.mjs";
|
|
|
|
import { applyAuthRoutes } from "./api/auth.mjs";
|
|
import { applyApiRoutes, applyPublicRoutes } from "./api/index.mjs";
|
|
import mongoose from "mongoose";
|
|
import { store } from "./store.mjs";
|
|
|
|
// express server
|
|
const port = 3000;
|
|
const app = express();
|
|
|
|
const router = express.Router();
|
|
const authRouter = express.Router();
|
|
const publicRouter = express.Router();
|
|
|
|
router.use(express.json());
|
|
authRouter.use(express.json());
|
|
publicRouter.use(express.json());
|
|
|
|
app
|
|
.use('/api/v1', router)
|
|
.use('/api/auth', authRouter)
|
|
.use('/api/public', publicRouter);
|
|
|
|
applyAuthRoutes(authRouter);
|
|
|
|
router.use(auth);
|
|
applyApiRoutes(router);
|
|
|
|
applyPublicRoutes(publicRouter);
|
|
|
|
await mongoose.connect(store.mongodbConnstring);
|
|
console.log('mongodb connected');
|
|
|
|
app.listen(port);
|
|
console.log('express started');
|