Skip to content

Commit 9f26fc7

Browse files
ManoloManolo
Manolo
authored and
Manolo
committed
add mock server
1 parent 2d928e9 commit 9f26fc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6838
-83
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_API_URL=http://localhost:3000

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
# environment
27+
.env

create-dev-env.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
4+
const file = path.join(import.meta.dirname, '.env');
5+
const exampleFile = path.join(import.meta.dirname, '.env.example');
6+
7+
if (!fs.existsSync(file)) {
8+
fs.copyFileSync(exampleFile, file);
9+
}

mock-server/.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NODE_ENV=development
2+
PORT=3000
3+
SIMULATED_DELAY=2000

mock-server/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
.env
4+
mongo-data

mock-server/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Lemoncode
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

mock-server/README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# gex-backend-node
2+
3+
>> Note: We must be installed almost Node.js 22.11.0 or higher.
4+
>>
5+
>> [Install Node.js](https://nodejs.org/)
6+
>>
7+
>> we can also use [nvm for windows](https://github.com/coreybutler/nvm-windows/releases) to manage the Node.js versions
8+
>> or for linux/macOS we can use [nvm](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating)
9+
10+
11+
## Steps to run the project
12+
13+
### Installation
14+
15+
```bash
16+
npm install
17+
```
18+
19+
### Run the project
20+
21+
Now you can run the project.
22+
23+
```bash
24+
npm start
25+
```
26+
27+
It's important start the project before running the console runners because we will create .env file, if we don't have it yet,
28+
and then the next step will be create the seed data in the database.
29+
30+
### Create seed data in the database
31+
32+
You can run the console runners to create seed data in the database.
33+
34+
```bash
35+
npm run start:console-runners
36+
```
37+
38+
Now, you can select the option to install seed data.
39+
40+
```bash
41+
❯ seed-data
42+
exit
43+
```
44+
45+
After select the option `seed-data` and you will insert the seed data in the database.
46+
47+
### Endpoints now available
48+
49+
#### Get users:
50+
51+
- [GET] http://localhost:3000/api/users
52+
- [GET] http://localhost:3000/api/users?page=1&pageSize=10
53+
54+
55+
56+

mock-server/create-dev-env.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
4+
const file = path.join(import.meta.dirname, '.env');
5+
const exampleFile = path.join(import.meta.dirname, '.env.example');
6+
7+
if (!fs.existsSync(file)) {
8+
fs.copyFileSync(exampleFile, file);
9+
}

0 commit comments

Comments
 (0)