Skip to content

Commit 8188852

Browse files
committed
adonis app with react set up
0 parents  commit 8188852

36 files changed

+32228
-0
lines changed

.babelrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "presets": [ "es2015", "react" ] }

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_size = 2
6+
indent_style = space
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.env.example

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
HOST=127.0.0.1
2+
PORT=3333
3+
NODE_ENV=development
4+
APP_URL=http://${HOST}:${PORT}
5+
6+
CACHE_VIEWS=false
7+
8+
APP_KEY=2wsjLSopTjD6WQEztTYIZgCFou8wpLJn
9+
10+
DB_CONNECTION=sqlite
11+
DB_HOST=127.0.0.1
12+
DB_PORT=3306
13+
DB_USER=root
14+
DB_PASSWORD=
15+
DB_DATABASE=adonis
16+
17+
SESSION_DRIVER=cookie

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Node modules
2+
node_modules
3+
4+
# Adonis directory for storing tmp files
5+
tmp
6+
7+
# Environment variables, never commit this file
8+
.env
9+
10+
# The development sqlite file
11+
database/development.sqlite

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Adonis fullstack application
2+
3+
This is the fullstack boilerplate for AdonisJs, it comes pre-configured with.
4+
5+
1. Bodyparser
6+
2. Session
7+
3. Authentication
8+
4. Web security middleware
9+
5. CORS
10+
6. Edge template engine
11+
7. Lucid ORM
12+
8. Migrations and seeds
13+
14+
## Setup
15+
16+
Use the adonis command to install the blueprint
17+
18+
```bash
19+
adonis new yardstick
20+
```
21+
22+
or manually clone the repo and then run `npm install`.
23+
24+
25+
### Migrations
26+
27+
Run the following command to run startup migrations.
28+
29+
```js
30+
adonis migration:run
31+
```

ace

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict'
2+
3+
/*
4+
|--------------------------------------------------------------------------
5+
| Ace Commands
6+
|--------------------------------------------------------------------------
7+
|
8+
| The ace file is just a regular Javascript file but with no extension. You
9+
| can call `node ace` followed by the command name and it just works.
10+
|
11+
| Also you can use `adonis` followed by the command name, since the adonis
12+
| global proxy all the ace commands.
13+
|
14+
*/
15+
16+
const { Ignitor } = require('@adonisjs/ignitor')
17+
18+
new Ignitor(require('@adonisjs/fold'))
19+
.appRoot(__dirname)
20+
.fireAce()
21+
.catch(console.error)

app/Models/Token.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict'
2+
3+
const Model = use('Model')
4+
5+
class Token extends Model {
6+
}
7+
8+
module.exports = Token

app/Models/User.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict'
2+
3+
const Hash = use('Hash')
4+
const Model = use('Model')
5+
6+
class User extends Model {
7+
static boot () {
8+
super.boot()
9+
10+
/**
11+
* A hook to hash the user password before saving
12+
* it to the database.
13+
*/
14+
this.addHook('beforeCreate', async (userInstance) => {
15+
if (userInstance.password) {
16+
userInstance.password = await Hash.make(userInstance.password)
17+
}
18+
})
19+
}
20+
21+
/**
22+
* A relationship on tokens is required for auth to
23+
* work. Since features like `refreshTokens` or
24+
* `rememberToken` will be saved inside the
25+
* tokens table.
26+
*
27+
* @method tokens
28+
*
29+
* @return {Object}
30+
*/
31+
tokens () {
32+
return this.hasMany('App/Models/Token')
33+
}
34+
}
35+
36+
module.exports = User

config/app.js

+210
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
'use strict'
2+
3+
const Env = use('Env')
4+
5+
module.exports = {
6+
/*
7+
|--------------------------------------------------------------------------
8+
| App Key
9+
|--------------------------------------------------------------------------
10+
|
11+
| App key is a randomly generated 16 or 32 characters long string required
12+
| to encrypted cookies, sessions and other sensitive data.
13+
|
14+
*/
15+
appKey: Env.get('APP_KEY'),
16+
17+
http: {
18+
/*
19+
|--------------------------------------------------------------------------
20+
| Allow Method Spoofing
21+
|--------------------------------------------------------------------------
22+
|
23+
| Method spoofing allows to make requests by spoofing the http verb.
24+
| Which means you can make a GET request but instruct the server to
25+
| treat as a POST or PUT request. If you want this feature, set the
26+
| below value to true.
27+
|
28+
*/
29+
allowMethodSpoofing: true,
30+
31+
/*
32+
|--------------------------------------------------------------------------
33+
| Trust Proxy
34+
|--------------------------------------------------------------------------
35+
|
36+
| Trust proxy defines whether X-Forwaded-* headers should be trusted or not.
37+
| When your application is behind a proxy server like nginx, these values
38+
| are set automatically and should be trusted. Apart from setting it
39+
| to true or false Adonis supports handful or ways to allow proxy
40+
| values. Read documentation for that.
41+
|
42+
*/
43+
trustProxy: false,
44+
45+
/*
46+
|--------------------------------------------------------------------------
47+
| Subdomains
48+
|--------------------------------------------------------------------------
49+
|
50+
| Offset to be used for returning subdomains for a given request.For
51+
| majority of applications it will be 2, until you have nested
52+
| sudomains.
53+
| cheatsheet.adonisjs.com - offset - 2
54+
| virk.cheatsheet.adonisjs.com - offset - 3
55+
|
56+
*/
57+
subdomainOffset: 2,
58+
59+
/*
60+
|--------------------------------------------------------------------------
61+
| JSONP Callback
62+
|--------------------------------------------------------------------------
63+
|
64+
| Default jsonp callback to be used when callback query string is missing
65+
| in request url.
66+
|
67+
*/
68+
jsonpCallback: 'callback',
69+
70+
/*
71+
|--------------------------------------------------------------------------
72+
| Etag
73+
|--------------------------------------------------------------------------
74+
|
75+
| Set etag on all HTTP response. In order to disable for selected routes,
76+
| you can call the `response.send` with an options object as follows.
77+
|
78+
| response.send('Hello', { ignoreEtag: true })
79+
|
80+
*/
81+
etag: false
82+
},
83+
84+
views: {
85+
/*
86+
|--------------------------------------------------------------------------
87+
| Cache Views
88+
|--------------------------------------------------------------------------
89+
|
90+
| Define whether or not to cache the compiled view. Set it to true in
91+
| production to optimize view loading time.
92+
|
93+
*/
94+
cache: Env.get('CACHE_VIEWS', true)
95+
},
96+
97+
static: {
98+
/*
99+
|--------------------------------------------------------------------------
100+
| Dot Files
101+
|--------------------------------------------------------------------------
102+
|
103+
| Define how to treat dot files when trying to server static resources.
104+
| By default it is set to ignore, which will pretend that dotfiles
105+
| does not exists.
106+
|
107+
| Can be one of the following
108+
| ignore, deny, allow
109+
|
110+
*/
111+
dotfiles: 'ignore',
112+
113+
/*
114+
|--------------------------------------------------------------------------
115+
| ETag
116+
|--------------------------------------------------------------------------
117+
|
118+
| Enable or disable etag generation
119+
|
120+
*/
121+
etag: true,
122+
123+
/*
124+
|--------------------------------------------------------------------------
125+
| Extensions
126+
|--------------------------------------------------------------------------
127+
|
128+
| Set file extension fallbacks. When set, if a file is not found, the given
129+
| extensions will be added to the file name and search for. The first
130+
| that exists will be served. Example: ['html', 'htm'].
131+
|
132+
*/
133+
extensions: false
134+
},
135+
136+
locales: {
137+
/*
138+
|--------------------------------------------------------------------------
139+
| Loader
140+
|--------------------------------------------------------------------------
141+
|
142+
| The loader to be used for fetching and updating locales. Below is the
143+
| list of available options.
144+
|
145+
| file, database
146+
|
147+
*/
148+
loader: 'file',
149+
150+
/*
151+
|--------------------------------------------------------------------------
152+
| Default Locale
153+
|--------------------------------------------------------------------------
154+
|
155+
| Default locale to be used by Antl provider. You can always switch drivers
156+
| in runtime or use the official Antl middleware to detect the driver
157+
| based on HTTP headers/query string.
158+
|
159+
*/
160+
locale: 'en'
161+
},
162+
163+
logger: {
164+
/*
165+
|--------------------------------------------------------------------------
166+
| Transport
167+
|--------------------------------------------------------------------------
168+
|
169+
| Transport to be used for logging messages. You can have multiple
170+
| transports using same driver.
171+
|
172+
| Available drivers are: `file` and `console`.
173+
|
174+
*/
175+
transport: 'console',
176+
177+
/*
178+
|--------------------------------------------------------------------------
179+
| Console Transport
180+
|--------------------------------------------------------------------------
181+
|
182+
| Using `console` driver for logging. This driver writes to `stdout`
183+
| and `stderr`
184+
|
185+
*/
186+
console: {
187+
driver: 'console',
188+
name: 'adonis-app',
189+
level: 'info'
190+
},
191+
192+
/*
193+
|--------------------------------------------------------------------------
194+
| File Transport
195+
|--------------------------------------------------------------------------
196+
|
197+
| File transport uses file driver and writes log messages for a given
198+
| file inside `tmp` directory for your app.
199+
|
200+
| For a different directory, set an absolute path for the filename.
201+
|
202+
*/
203+
file: {
204+
driver: 'file',
205+
name: 'adonis-app',
206+
filename: 'adonis.log',
207+
level: 'info'
208+
}
209+
}
210+
}

0 commit comments

Comments
 (0)