-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
mock-server.ts
30 lines (25 loc) · 708 Bytes
/
mock-server.ts
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
import { createMiddleware } from '@mswjs/http-middleware';
import cors from 'cors';
import express from 'express';
import logger from 'pino-http';
import { env } from './src/config/env';
import { initializeDb } from './src/testing/mocks/db';
import { handlers } from './src/testing/mocks/handlers';
const app = express();
app.use(
cors({
origin: env.APP_URL,
credentials: true,
}),
);
app.use(express.json());
app.use(logger());
app.use(createMiddleware(...handlers));
initializeDb().then(() => {
console.log('Mock DB initialized');
app.listen(env.APP_MOCK_API_PORT, () => {
console.log(
`Mock API server started at http:https://localhost:${env.APP_MOCK_API_PORT}`,
);
});
});