-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from alan2207/standalone-mock-server
add standalone mock server
- Loading branch information
Showing
20 changed files
with
966 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
VITE_APP_API_URL=https://api.bulletproofapp.com | ||
VITE_APP_ENABLE_API_MOCKING=true | ||
VITE_APP_ENABLE_API_MOCKING=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
VITE_APP_API_URL=http://localhost:8080/api | ||
VITE_APP_ENABLE_API_MOCKING=false | ||
VITE_APP_MOCK_API_PORT=8080 | ||
VITE_APP_URL=http://localhost:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,7 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
|
||
# local | ||
mocked-db.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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://localhost:${env.APP_MOCK_API_PORT}`, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.