Skip to content

Commit 79d8339

Browse files
authored
fix: Environment installation (#90)
* feat: rewrite .env.example * feat: add prisma push command * fix: put a valid database url by default and documentate it * docs: Fix README * chore(ide): Update data source * chore: Improve reset and seed make commands * docs: Add disclaimer for hardcoded credentials * docs: Add how generate NEXTAUTH_SECRET * fix: rewrite .env.example * fix: improve .env.example
1 parent 5991cfd commit 79d8339

File tree

5 files changed

+68
-41
lines changed

5 files changed

+68
-41
lines changed

.env.example

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
# For the local environment, you don't need to replace values
2+
# For others environments, you need to replace at least DATABASE_USER, DATABASE_PASSWORD, DATABASE_HOST, DATABASE_URL, NEXTAUTH_SECRET and NEXTAUTH_URL
3+
14
# Database
2-
DATABASE_PROVIDER=your_database_provider
3-
DATABASE_NAME=your_database_name
4-
DATABASE_USER=your_database_user
5-
DATABASE_PASSWORD=your_database_user_password
6-
DATABASE_HOST=your_database_host
7-
DATABASE_PORT=your_database_port
8-
DATABASE_URL=your_database_url
5+
DATABASE_PROVIDER="postgresql"
6+
DATABASE_NAME="locklite_app"
7+
DATABASE_USER="locklite"
8+
DATABASE_PASSWORD="locklite"
9+
DATABASE_HOST="localhost"
10+
DATABASE_PORT=5432
11+
#DATABASE_URL="postgres://DATABASE_USER:DATABASE_PASSWORD@DATABASE_HOST:DATABASE_PORT/DATABASE_NAME"
12+
DATABASE_URL="postgres://locklite:locklite@localhost:5432/locklite_app"
913

1014
# Next Auth
11-
NEXTAUTH_SECRET=your_nextauth_secret
12-
NEXTAUTH_URL=your_nextauth_url
15+
# Generate your own unique secret for each environment. You can use `openssl rand -base64 32` or `npx next-auth secret` to generate one.
16+
NEXTAUTH_SECRET="your_nextauth_secret"
17+
NEXTAUTH_URL="http://localhost:3000"
1318

1419
# Security
15-
BCRYPT_SALT_ROUNDS=your_bcrypt_salt_rounds
20+
BCRYPT_SALT_ROUNDS=12

.idea/dataSources.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,21 @@ migrate: up
5353
fi
5454
npm run prisma:migrate "$(MIGRATION_NAME)"
5555

56-
seed: up
56+
reset: up
5757
npm run prisma:reset
58+
59+
seed: up
5860
npm run prisma:seed
5961

6062
clean:
6163
rm -rf .next node_modules package-lock.json
6264
npm install
6365

64-
.PHONY: up down dev build lint format tests tests-shared tests-api tests-ui coverage migrate seed clean
66+
.PHONY: up down dev build lint format tests tests-shared tests-api tests-ui coverage migrate reset seed clean
6567

6668
# Aliases
6769
run: up dev
6870
checks: lint tests
71+
reset_db: reset seed
6972
ci: lint coverage build
7073
.PHONY: run checks ci

README.md

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,35 +44,41 @@ We recommend using a WSL for this project. If so, please follow the [Linux](#lin
4444

4545
### Installation
4646

47-
1. Create a `.env` file by copying the example file `.env.example` file. Replace the default values with your own.
47+
1. Create a `.env` file by copying the example file `.env.example` file. These values are only for the local environment, you can modify it if you want.
4848

49-
2. You need to install NodeJS packages
49+
2. Start docker services with the following command
5050

5151
```shell
52-
npm install
52+
docker-compose up -d
5353
```
5454

55-
### Getting Started
55+
3. You need to install NodeJS packages
56+
57+
```shell
58+
npm install
59+
```
5660

57-
1. Start docker services with the following command
61+
4. Generate database schema
5862

5963
```shell
60-
docker-compose up -d
64+
npm run prisma:push
6165
```
6266

63-
2. Generate data with Prisma seed
67+
5. Generate data with Prisma seed
6468

6569
```shell
6670
npm run prisma:seed
6771
```
6872

69-
3. Launch the application in development mode
73+
### Getting Started
74+
75+
1. Launch the application in development mode
7076

7177
```shell
7278
npm run dev
7379
```
7480

75-
4. Well done, the application is running!
81+
2. Well done, the application is running!
7682

7783
- UI : http://localhost:3000/ui (homepage)
7884
- API : http://localhost:3000/api/docs (Swagger documentation)
@@ -104,35 +110,41 @@ npm run prisma:seed
104110

105111
### Installation
106112

107-
1. Create a `.env` file by copying the example file `.env.example` file. Replace the default values with your own.
113+
1. Create a `.env` file by copying the example file `.env.example` file. You can modify it if you want.
108114

109-
2. You need to install NodeJS packages
115+
2. Start docker services with the following command
110116

111117
```shell
112-
npm install
118+
docker-compose up -d
113119
```
114120

115-
### Getting Started
121+
3. You need to install NodeJS packages
122+
123+
```shell
124+
npm install
125+
```
116126

117-
1. Start docker services with the following command
127+
4. Generate database schema
118128

119129
```shell
120-
docker-compose up -d
130+
npm run prisma:push
121131
```
122132

123-
2. Generate data with Prisma seed
133+
5. Generate data with Prisma seed
124134

125135
```shell
126136
npm run prisma:seed
127137
```
128138

129-
3. Launch the application in development mode
139+
### Getting Started
140+
141+
1. Launch the application in development mode
130142

131143
```shell
132144
npm run dev
133145
```
134146

135-
4. Well done, the application is running!
147+
2. Well done, the application is running!
136148

137149
- UI : http://localhost:3000/ui (homepage)
138150
- API : http://localhost:3000/api/docs (Swagger documentation)
@@ -164,35 +176,41 @@ npm run prisma:seed
164176

165177
### Installation
166178

167-
1. Create a `.env` file by copying the example file `.env.example` file. Replace the default values with your own.
179+
1. Create a `.env` file by copying the example file `.env.example` file. You can modify it if you want.
168180

169-
2. You need to install NodeJS packages
181+
2. Start docker services with the following command
170182

171183
```shell
172-
npm install
184+
docker-compose up -d
173185
```
174186

175-
### Getting Started
187+
3. You need to install NodeJS packages
176188

177-
1. Start docker services with the following command
189+
```shell
190+
npm install
191+
```
192+
193+
4. Generate database schema
178194

179195
```shell
180-
docker-compose up -d
196+
npm run prisma:push
181197
```
182198

183-
2. Generate data with Prisma seed
199+
5. Generate data with Prisma seed
184200

185201
```shell
186202
npm run prisma:seed
187203
```
188204

189-
3. Launch the application in development mode
205+
### Getting Started
206+
207+
1. Launch the application in development mode
190208

191209
```shell
192210
npm run dev
193211
```
194212

195-
4. Well done, the application is running!
213+
2. Well done, the application is running!
196214

197215
- UI : http://localhost:3000/ui (homepage)
198216
- API : http://localhost:3000/api/docs (Swagger documentation)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"prisma:reset": "prisma migrate reset",
1919
"prisma:migrate": "prisma migrate dev --name",
2020
"prisma:generate": "prisma generate",
21+
"prisma:push": "prisma db push",
2122
"prisma:seed": "tsx src/modules/api/infra/prisma/seed/seed.ts"
2223
},
2324
"dependencies": {

0 commit comments

Comments
 (0)