aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorLibravatar vantezzen <properly@protonmail.com>2019-08-22 11:12:36 +0200
committerLibravatar vantezzen <properly@protonmail.com>2019-08-22 11:12:36 +0200
commitb018adf240679ec59a7344e30be39400f1ecd8af (patch)
treec076635761667dad302716b498088f1047281e46 /config
downloadferdium-server-b018adf240679ec59a7344e30be39400f1ecd8af.tar.gz
ferdium-server-b018adf240679ec59a7344e30be39400f1ecd8af.tar.zst
ferdium-server-b018adf240679ec59a7344e30be39400f1ecd8af.zip
Initial commit
Diffstat (limited to 'config')
-rw-r--r--config/app.js243
-rw-r--r--config/auth.js94
-rw-r--r--config/bodyParser.js157
-rw-r--r--config/cors.js87
-rw-r--r--config/database.js84
-rw-r--r--config/hash.js49
6 files changed, 714 insertions, 0 deletions
diff --git a/config/app.js b/config/app.js
new file mode 100644
index 0000000..4b4f7a5
--- /dev/null
+++ b/config/app.js
@@ -0,0 +1,243 @@
1'use strict'
2
3/** @type {import('@adonisjs/framework/src/Env')} */
4const Env = use('Env')
5
6module.exports = {
7
8 /*
9 |--------------------------------------------------------------------------
10 | Application Name
11 |--------------------------------------------------------------------------
12 |
13 | This value is the name of your application and can used when you
14 | need to place the application's name in a email, view or
15 | other location.
16 |
17 */
18
19 name: Env.get('APP_NAME', 'AdonisJs'),
20
21 /*
22 |--------------------------------------------------------------------------
23 | App Key
24 |--------------------------------------------------------------------------
25 |
26 | App key is a randomly generated 16 or 32 characters long string required
27 | to encrypt cookies, sessions and other sensitive data.
28 |
29 */
30 appKey: Env.getOrFail('APP_KEY'),
31
32 http: {
33 /*
34 |--------------------------------------------------------------------------
35 | Allow Method Spoofing
36 |--------------------------------------------------------------------------
37 |
38 | Method spoofing allows to make requests by spoofing the http verb.
39 | Which means you can make a GET request but instruct the server to
40 | treat as a POST or PUT request. If you want this feature, set the
41 | below value to true.
42 |
43 */
44 allowMethodSpoofing: true,
45
46 /*
47 |--------------------------------------------------------------------------
48 | Trust Proxy
49 |--------------------------------------------------------------------------
50 |
51 | Trust proxy defines whether X-Forwarded-* headers should be trusted or not.
52 | When your application is behind a proxy server like nginx, these values
53 | are set automatically and should be trusted. Apart from setting it
54 | to true or false Adonis supports handful or ways to allow proxy
55 | values. Read documentation for that.
56 |
57 */
58 trustProxy: false,
59
60 /*
61 |--------------------------------------------------------------------------
62 | Subdomains
63 |--------------------------------------------------------------------------
64 |
65 | Offset to be used for returning subdomains for a given request.For
66 | majority of applications it will be 2, until you have nested
67 | sudomains.
68 | cheatsheet.adonisjs.com - offset - 2
69 | virk.cheatsheet.adonisjs.com - offset - 3
70 |
71 */
72 subdomainOffset: 2,
73
74 /*
75 |--------------------------------------------------------------------------
76 | JSONP Callback
77 |--------------------------------------------------------------------------
78 |
79 | Default jsonp callback to be used when callback query string is missing
80 | in request url.
81 |
82 */
83 jsonpCallback: 'callback',
84
85
86 /*
87 |--------------------------------------------------------------------------
88 | Etag
89 |--------------------------------------------------------------------------
90 |
91 | Set etag on all HTTP response. In order to disable for selected routes,
92 | you can call the `response.send` with an options object as follows.
93 |
94 | response.send('Hello', { ignoreEtag: true })
95 |
96 */
97 etag: false
98 },
99
100 views: {
101 /*
102 |--------------------------------------------------------------------------
103 | Cache Views
104 |--------------------------------------------------------------------------
105 |
106 | Define whether or not to cache the compiled view. Set it to true in
107 | production to optimize view loading time.
108 |
109 */
110 cache: Env.get('CACHE_VIEWS', true)
111 },
112
113 static: {
114 /*
115 |--------------------------------------------------------------------------
116 | Dot Files
117 |--------------------------------------------------------------------------
118 |
119 | Define how to treat dot files when trying to server static resources.
120 | By default it is set to ignore, which will pretend that dotfiles
121 | does not exists.
122 |
123 | Can be one of the following
124 | ignore, deny, allow
125 |
126 */
127 dotfiles: 'ignore',
128
129 /*
130 |--------------------------------------------------------------------------
131 | ETag
132 |--------------------------------------------------------------------------
133 |
134 | Enable or disable etag generation
135 |
136 */
137 etag: true,
138
139 /*
140 |--------------------------------------------------------------------------
141 | Extensions
142 |--------------------------------------------------------------------------
143 |
144 | Set file extension fallbacks. When set, if a file is not found, the given
145 | extensions will be added to the file name and search for. The first
146 | that exists will be served. Example: ['html', 'htm'].
147 |
148 */
149 extensions: false
150 },
151
152 locales: {
153 /*
154 |--------------------------------------------------------------------------
155 | Loader
156 |--------------------------------------------------------------------------
157 |
158 | The loader to be used for fetching and updating locales. Below is the
159 | list of available options.
160 |
161 | file, database
162 |
163 */
164 loader: 'file',
165
166 /*
167 |--------------------------------------------------------------------------
168 | Default Locale
169 |--------------------------------------------------------------------------
170 |
171 | Default locale to be used by Antl provider. You can always switch drivers
172 | in runtime or use the official Antl middleware to detect the driver
173 | based on HTTP headers/query string.
174 |
175 */
176 locale: 'en'
177 },
178
179 logger: {
180 /*
181 |--------------------------------------------------------------------------
182 | Transport
183 |--------------------------------------------------------------------------
184 |
185 | Transport to be used for logging messages. You can have multiple
186 | transports using same driver.
187 |
188 | Available drivers are: `file` and `console`.
189 |
190 */
191 transport: 'console',
192
193 /*
194 |--------------------------------------------------------------------------
195 | Console Transport
196 |--------------------------------------------------------------------------
197 |
198 | Using `console` driver for logging. This driver writes to `stdout`
199 | and `stderr`
200 |
201 */
202 console: {
203 driver: 'console',
204 name: 'adonis-app',
205 level: 'info'
206 },
207
208 /*
209 |--------------------------------------------------------------------------
210 | File Transport
211 |--------------------------------------------------------------------------
212 |
213 | File transport uses file driver and writes log messages for a given
214 | file inside `tmp` directory for your app.
215 |
216 | For a different directory, set an absolute path for the filename.
217 |
218 */
219 file: {
220 driver: 'file',
221 name: 'adonis-app',
222 filename: 'adonis.log',
223 level: 'info'
224 }
225 },
226
227 /*
228 |--------------------------------------------------------------------------
229 | Generic Cookie Options
230 |--------------------------------------------------------------------------
231 |
232 | The following cookie options are generic settings used by AdonisJs to create
233 | cookies. However, some parts of the application like `sessions` can have
234 | separate settings for cookies inside `config/session.js`.
235 |
236 */
237 cookie: {
238 httpOnly: true,
239 sameSite: false,
240 path: '/',
241 maxAge: 7200
242 }
243}
diff --git a/config/auth.js b/config/auth.js
new file mode 100644
index 0000000..c70db3f
--- /dev/null
+++ b/config/auth.js
@@ -0,0 +1,94 @@
1'use strict'
2
3/** @type {import('@adonisjs/framework/src/Env')} */
4const Env = use('Env')
5
6module.exports = {
7 /*
8 |--------------------------------------------------------------------------
9 | Authenticator
10 |--------------------------------------------------------------------------
11 |
12 | Authentication is a combination of serializer and scheme with extra
13 | config to define on how to authenticate a user.
14 |
15 | Available Schemes - basic, session, jwt, api
16 | Available Serializers - lucid, database
17 |
18 */
19 authenticator: 'jwt',
20
21 /*
22 |--------------------------------------------------------------------------
23 | Session
24 |--------------------------------------------------------------------------
25 |
26 | Session authenticator makes use of sessions to authenticate a user.
27 | Session authentication is always persistent.
28 |
29 */
30 session: {
31 serializer: 'lucid',
32 model: 'App/Models/User',
33 scheme: 'session',
34 uid: 'email',
35 password: 'password'
36 },
37
38 /*
39 |--------------------------------------------------------------------------
40 | Basic Auth
41 |--------------------------------------------------------------------------
42 |
43 | The basic auth authenticator uses basic auth header to authenticate a
44 | user.
45 |
46 | NOTE:
47 | This scheme is not persistent and users are supposed to pass
48 | login credentials on each request.
49 |
50 */
51 basic: {
52 serializer: 'lucid',
53 model: 'App/Models/User',
54 scheme: 'basic',
55 uid: 'email',
56 password: 'password'
57 },
58
59 /*
60 |--------------------------------------------------------------------------
61 | Jwt
62 |--------------------------------------------------------------------------
63 |
64 | The jwt authenticator works by passing a jwt token on each HTTP request
65 | via HTTP `Authorization` header.
66 |
67 */
68 jwt: {
69 serializer: 'lucid',
70 model: 'App/Models/User',
71 scheme: 'jwt',
72 uid: 'email',
73 password: 'password',
74 options: {
75 secret: Env.get('APP_KEY')
76 }
77 },
78
79 /*
80 |--------------------------------------------------------------------------
81 | Api
82 |--------------------------------------------------------------------------
83 |
84 | The Api scheme makes use of API personal tokens to authenticate a user.
85 |
86 */
87 api: {
88 serializer: 'lucid',
89 model: 'App/Models/User',
90 scheme: 'api',
91 uid: 'email',
92 password: 'password'
93 }
94}
diff --git a/config/bodyParser.js b/config/bodyParser.js
new file mode 100644
index 0000000..c481b01
--- /dev/null
+++ b/config/bodyParser.js
@@ -0,0 +1,157 @@
1'use strict'
2
3module.exports = {
4 /*
5 |--------------------------------------------------------------------------
6 | JSON Parser
7 |--------------------------------------------------------------------------
8 |
9 | Below settings are applied when the request body contains a JSON payload.
10 | If you want body parser to ignore JSON payloads, then simply set `types`
11 | to an empty array.
12 */
13 json: {
14 /*
15 |--------------------------------------------------------------------------
16 | limit
17 |--------------------------------------------------------------------------
18 |
19 | Defines the limit of JSON that can be sent by the client. If payload
20 | is over 1mb it will not be processed.
21 |
22 */
23 limit: '1mb',
24
25 /*
26 |--------------------------------------------------------------------------
27 | strict
28 |--------------------------------------------------------------------------
29 |
30 | When `strict` is set to true, body parser will only parse Arrays and
31 | Object. Otherwise everything parseable by `JSON.parse` is parsed.
32 |
33 */
34 strict: true,
35
36 /*
37 |--------------------------------------------------------------------------
38 | types
39 |--------------------------------------------------------------------------
40 |
41 | Which content types are processed as JSON payloads. You are free to
42 | add your own types here, but the request body should be parseable
43 | by `JSON.parse` method.
44 |
45 */
46 types: [
47 'application/json',
48 'application/json-patch+json',
49 'application/vnd.api+json',
50 'application/csp-report'
51 ]
52 },
53
54 /*
55 |--------------------------------------------------------------------------
56 | Raw Parser
57 |--------------------------------------------------------------------------
58 |
59 |
60 |
61 */
62 raw: {
63 types: [
64 'text/*'
65 ]
66 },
67
68 /*
69 |--------------------------------------------------------------------------
70 | Form Parser
71 |--------------------------------------------------------------------------
72 |
73 |
74 |
75 */
76 form: {
77 types: [
78 'application/x-www-form-urlencoded'
79 ]
80 },
81
82 /*
83 |--------------------------------------------------------------------------
84 | Files Parser
85 |--------------------------------------------------------------------------
86 |
87 |
88 |
89 */
90 files: {
91 types: [
92 'multipart/form-data'
93 ],
94
95 /*
96 |--------------------------------------------------------------------------
97 | Max Size
98 |--------------------------------------------------------------------------
99 |
100 | Below value is the max size of all the files uploaded to the server. It
101 | is validated even before files have been processed and hard exception
102 | is thrown.
103 |
104 | Consider setting a reasonable value here, otherwise people may upload GB's
105 | of files which will keep your server busy.
106 |
107 | Also this value is considered when `autoProcess` is set to true.
108 |
109 */
110 maxSize: '20mb',
111
112 /*
113 |--------------------------------------------------------------------------
114 | Auto Process
115 |--------------------------------------------------------------------------
116 |
117 | Whether or not to auto-process files. Since HTTP servers handle files via
118 | couple of specific endpoints. It is better to set this value off and
119 | manually process the files when required.
120 |
121 | This value can contain a boolean or an array of route patterns
122 | to be autoprocessed.
123 */
124 autoProcess: true,
125
126 /*
127 |--------------------------------------------------------------------------
128 | Process Manually
129 |--------------------------------------------------------------------------
130 |
131 | The list of routes that should not process files and instead rely on
132 | manual process. This list should only contain routes when autoProcess
133 | is to true. Otherwise everything is processed manually.
134 |
135 */
136 processManually: []
137
138 /*
139 |--------------------------------------------------------------------------
140 | Temporary file name
141 |--------------------------------------------------------------------------
142 |
143 | Define a function, which should return a string to be used as the
144 | tmp file name.
145 |
146 | If not defined, Bodyparser will use `uuid` as the tmp file name.
147 |
148 | To be defined as. If you are defining the function, then do make sure
149 | to return a value from it.
150 |
151 | tmpFileName () {
152 | return 'some-unique-value'
153 | }
154 |
155 */
156 }
157}
diff --git a/config/cors.js b/config/cors.js
new file mode 100644
index 0000000..ffc1951
--- /dev/null
+++ b/config/cors.js
@@ -0,0 +1,87 @@
1'use strict'
2
3module.exports = {
4 /*
5 |--------------------------------------------------------------------------
6 | Origin
7 |--------------------------------------------------------------------------
8 |
9 | Set a list of origins to be allowed. The value can be one of the following
10 |
11 | Boolean: true - Allow current request origin
12 | Boolean: false - Disallow all
13 | String - Comma separated list of allowed origins
14 | Array - An array of allowed origins
15 | String: * - A wildcard to allow current request origin
16 | Function - Receives the current origin and should return one of the above values.
17 |
18 */
19 origin: false,
20
21 /*
22 |--------------------------------------------------------------------------
23 | Methods
24 |--------------------------------------------------------------------------
25 |
26 | HTTP methods to be allowed. The value can be one of the following
27 |
28 | String - Comma separated list of allowed methods
29 | Array - An array of allowed methods
30 |
31 */
32 methods: ['GET', 'PUT', 'PATCH', 'POST', 'DELETE'],
33
34 /*
35 |--------------------------------------------------------------------------
36 | Headers
37 |--------------------------------------------------------------------------
38 |
39 | List of headers to be allowed via Access-Control-Request-Headers header.
40 | The value can be one of the following.
41 |
42 | Boolean: true - Allow current request headers
43 | Boolean: false - Disallow all
44 | String - Comma separated list of allowed headers
45 | Array - An array of allowed headers
46 | String: * - A wildcard to allow current request headers
47 | Function - Receives the current header and should return one of the above values.
48 |
49 */
50 headers: true,
51
52 /*
53 |--------------------------------------------------------------------------
54 | Expose Headers
55 |--------------------------------------------------------------------------
56 |
57 | A list of headers to be exposed via `Access-Control-Expose-Headers`
58 | header. The value can be one of the following.
59 |
60 | Boolean: false - Disallow all
61 | String: Comma separated list of allowed headers
62 | Array - An array of allowed headers
63 |
64 */
65 exposeHeaders: false,
66
67 /*
68 |--------------------------------------------------------------------------
69 | Credentials
70 |--------------------------------------------------------------------------
71 |
72 | Define Access-Control-Allow-Credentials header. It should always be a
73 | boolean.
74 |
75 */
76 credentials: false,
77
78 /*
79 |--------------------------------------------------------------------------
80 | MaxAge
81 |--------------------------------------------------------------------------
82 |
83 | Define Access-Control-Allow-Max-Age
84 |
85 */
86 maxAge: 90
87}
diff --git a/config/database.js b/config/database.js
new file mode 100644
index 0000000..a7a2776
--- /dev/null
+++ b/config/database.js
@@ -0,0 +1,84 @@
1'use strict'
2
3/** @type {import('@adonisjs/framework/src/Env')} */
4const Env = use('Env')
5
6/** @type {import('@adonisjs/ignitor/src/Helpers')} */
7const Helpers = use('Helpers')
8
9module.exports = {
10 /*
11 |--------------------------------------------------------------------------
12 | Default Connection
13 |--------------------------------------------------------------------------
14 |
15 | Connection defines the default connection settings to be used while
16 | interacting with SQL databases.
17 |
18 */
19 connection: Env.get('DB_CONNECTION', 'sqlite'),
20
21 /*
22 |--------------------------------------------------------------------------
23 | Sqlite
24 |--------------------------------------------------------------------------
25 |
26 | Sqlite is a flat file database and can be a good choice for a development
27 | environment.
28 |
29 | npm i --save sqlite3
30 |
31 */
32 sqlite: {
33 client: 'sqlite3',
34 connection: {
35 filename: Helpers.databasePath(`${Env.get('DB_DATABASE', 'development')}.sqlite`)
36 },
37 useNullAsDefault: true,
38 debug: Env.get('DB_DEBUG', false)
39 },
40
41 /*
42 |--------------------------------------------------------------------------
43 | MySQL
44 |--------------------------------------------------------------------------
45 |
46 | Here we define connection settings for MySQL database.
47 |
48 | npm i --save mysql
49 |
50 */
51 mysql: {
52 client: 'mysql',
53 connection: {
54 host: Env.get('DB_HOST', 'localhost'),
55 port: Env.get('DB_PORT', ''),
56 user: Env.get('DB_USER', 'root'),
57 password: Env.get('DB_PASSWORD', ''),
58 database: Env.get('DB_DATABASE', 'adonis')
59 },
60 debug: Env.get('DB_DEBUG', false)
61 },
62
63 /*
64 |--------------------------------------------------------------------------
65 | PostgreSQL
66 |--------------------------------------------------------------------------
67 |
68 | Here we define connection settings for PostgreSQL database.
69 |
70 | npm i --save pg
71 |
72 */
73 pg: {
74 client: 'pg',
75 connection: {
76 host: Env.get('DB_HOST', 'localhost'),
77 port: Env.get('DB_PORT', ''),
78 user: Env.get('DB_USER', 'root'),
79 password: Env.get('DB_PASSWORD', ''),
80 database: Env.get('DB_DATABASE', 'adonis')
81 },
82 debug: Env.get('DB_DEBUG', false)
83 }
84}
diff --git a/config/hash.js b/config/hash.js
new file mode 100644
index 0000000..42f5805
--- /dev/null
+++ b/config/hash.js
@@ -0,0 +1,49 @@
1'use strict'
2
3/** @type {import('@adonisjs/framework/src/Env')} */
4const Env = use('Env')
5
6module.exports = {
7 /*
8 |--------------------------------------------------------------------------
9 | Driver
10 |--------------------------------------------------------------------------
11 |
12 | Driver to be used for hashing values. The same driver is used by the
13 | auth module too.
14 |
15 */
16 driver: Env.get('HASH_DRIVER', 'bcrypt'),
17
18 /*
19 |--------------------------------------------------------------------------
20 | Bcrypt
21 |--------------------------------------------------------------------------
22 |
23 | Config related to bcrypt hashing. https://www.npmjs.com/package/bcrypt
24 | package is used internally.
25 |
26 */
27 bcrypt: {
28 rounds: 10
29 },
30
31 /*
32 |--------------------------------------------------------------------------
33 | Argon
34 |--------------------------------------------------------------------------
35 |
36 | Config related to argon. https://www.npmjs.com/package/argon2 package is
37 | used internally.
38 |
39 | Since argon is optional, you will have to install the dependency yourself
40 |
41 |============================================================================
42 | npm i argon2
43 |============================================================================
44 |
45 */
46 argon: {
47 type: 1
48 }
49}