create-sip 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,241 @@
1
+ # User documentation
2
+
3
+ ## Install dependencies
4
+
5
+ Dependencies must be installed before use.
6
+
7
+ ```cmd
8
+ npm install
9
+ ```
10
+
11
+ Or use your favorite package manager.
12
+
13
+ ## Generate config file
14
+
15
+ The settings are located in a file called:
16
+
17
+ * .env
18
+
19
+ To generate the .env file:
20
+
21
+ ```cmd
22
+ node op conf:generate
23
+ ```
24
+
25
+ ### Test configurations file generate
26
+
27
+ ```cmd
28
+ node op testconf:generate
29
+ ```
30
+
31
+ Result: .env.test file.
32
+
33
+ ## App key generation
34
+
35
+ Te generate the application key:
36
+
37
+ ```cmd
38
+ node op key:generate
39
+ ```
40
+
41
+ ## Database setup
42
+
43
+ Edit the .env file.
44
+
45
+ ## Endpoints
46
+
47
+ All endpoint have a /api prefix.
48
+
49
+ | Endpoint | Method | Auth | Description |
50
+ |-|-|-|-|
51
+ | /register | POST | no | create user |
52
+ | /login | POST | no | login |
53
+ | /users | GET | yes | read users |
54
+ | /users/:id | GET | yes | read user |
55
+ | /users/:id/password | PUT | yes | change password |
56
+
57
+ ## The register endpoint
58
+
59
+ ```json
60
+ {
61
+ "name": "joe",
62
+ "email": "joe@green.lan",
63
+ "password": "secret",
64
+ "password_confirmation": "secret"
65
+ }
66
+ ```
67
+
68
+ ## The login endpoint
69
+
70
+ ```json
71
+ {
72
+ "name": "joe",
73
+ "password": "secret"
74
+ }
75
+ ```
76
+
77
+ You receive the bearear token with accessToken key.
78
+
79
+ ## The users endpoint
80
+
81
+ To query users or user, send the bearer token to endpoint.
82
+
83
+ ## Model and controller generation
84
+
85
+ Use the following instructions to generate models and controllers:
86
+
87
+ ```cmd
88
+ node op make:model thing
89
+ node op make:controller thing
90
+ ```
91
+
92
+ ## Key generation
93
+
94
+ You can generate the application key with the following command:
95
+
96
+ ```cmd
97
+ node op key:generate
98
+ ```
99
+
100
+ ## Generate admin user
101
+
102
+ You can create an admin user if it does not already exist in the database:
103
+
104
+ ```cmd
105
+ node op admin:generate
106
+ ```
107
+
108
+ ## Database import
109
+
110
+ It is possible to import data from JSON and CSV files.
111
+
112
+ ```cmd
113
+ node op db:import thing things.json
114
+ node op db:import thing things.csv
115
+ node op db:import thing things.csv ,
116
+ node op db:import thing things.csv ";"
117
+ node op db:import thing things.csv :
118
+ ```
119
+
120
+ The last option is the separator.
121
+
122
+ For example JSON file:
123
+
124
+ employees.json:
125
+
126
+ ```json
127
+ [
128
+ { "id": 1, "name": "Tom Large" },
129
+ { "id": 2, "name": "Jack Small" }
130
+ ]
131
+ ```
132
+
133
+ The default separator is comma.
134
+
135
+ ```cmd
136
+ node op db:import employee employees.json
137
+ ```
138
+
139
+ For example CSV file:
140
+
141
+ employees.csv:
142
+
143
+ ```csv
144
+ id,name
145
+ 1,Joe Kitin
146
+ 2,Peter Fall
147
+ ```
148
+
149
+ If you have colon separator, use sep parameter.
150
+
151
+ ```csv
152
+ id:name
153
+ 1:Joe Kitin
154
+ 2:Peter Fall
155
+ ```
156
+
157
+ ```cmd
158
+ node op db:import employee employees.csv --sep :
159
+ ```
160
+
161
+ If the file has semicolon separator, use sep parameter, for example:
162
+
163
+ ```csv
164
+ id;name
165
+ 1;Joe Kitin
166
+ 2;Peter Fall
167
+ ```
168
+
169
+ Use next command:
170
+
171
+ ```cmd
172
+ node op db:import employee employees.csv --sep ";"
173
+ ```
174
+
175
+ ## Database
176
+
177
+ ### Database synchronization
178
+
179
+ Models and database tables can be synchronized, but this can be dangerous.
180
+
181
+ Database synchronization can be set up in the app/models/modrels.js file. Default values are:
182
+
183
+ ```js
184
+ { alter: true }
185
+ ```
186
+
187
+ This preserves the data and existing structure.
188
+
189
+ Possible values:
190
+
191
+ ```js
192
+ { force: true }
193
+ ```
194
+
195
+ The latter deletes the contents of the database table!
196
+
197
+ If the value is false, there is no synchronization in either case.
198
+
199
+ ### Migration
200
+
201
+ Generate a migration:
202
+
203
+ ```bash
204
+ node op make/migration thing
205
+ ```
206
+
207
+ Run all migration:
208
+
209
+ ```bash
210
+ node op migration:run
211
+ ```
212
+
213
+ Run a migration:
214
+
215
+ ```bash
216
+ node op migration:run <migration_name>
217
+ ```
218
+
219
+ Rollback a migration:
220
+
221
+ ```bash
222
+ node op migration:rollback
223
+ ```
224
+
225
+ Rollback two migrations:
226
+
227
+ ```bash
228
+ node op migration:rollback 2
229
+ ```
230
+
231
+ Reset the database:
232
+
233
+ ```bash
234
+ node op migration:reset
235
+ ```
236
+
237
+ Reset the database and run all migrations:
238
+
239
+ ```bash
240
+ node op migration:fresh
241
+ ```
@@ -0,0 +1,4 @@
1
+ {
2
+ "watch": ["app", "config"],
3
+ "ext": ".js,.json"
4
+ }