Skip to content

Commit 7896f87

Browse files
alex-braunTobiTenno
authored andcommitted
feat: modernize template, newer express patterns
0 parents  commit 7896f87

37 files changed

+7396
-0
lines changed

.editorconfig

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
indent_style = space
13+
indent_size = 2
14+
15+
[*.js]
16+
indent_style = space
17+
indent_size = 2
18+
19+
[*.rb]
20+
indent_style = space
21+
indent_size = 2
22+
23+
[*.hbs]
24+
insert_final_newline = false
25+
indent_style = space
26+
indent_size = 2
27+
28+
[*.css]
29+
indent_style = space
30+
indent_size = 2
31+
32+
[*.html]
33+
indent_style = space
34+
indent_size = 2
35+
36+
[*.{diff,md}]
37+
trim_trailing_whitespace = false

.gitignore

+272
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
2+
# Created by https://www.gitignore.io/api/node,osx,linux,windows,ruby,node,rails,express,ember
3+
4+
### Node ###
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
10+
# Runtime data
11+
pids
12+
*.pid
13+
*.seed
14+
*.pid.lock
15+
16+
# Directory for instrumented libs generated by jscoverage/JSCover
17+
lib-cov
18+
19+
# Coverage directory used by tools like istanbul
20+
coverage
21+
22+
# nyc test coverage
23+
.nyc_output
24+
25+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26+
.grunt
27+
28+
# node-waf configuration
29+
.lock-wscript
30+
31+
# Compiled binary addons (http://nodejs.org/api/addons.html)
32+
build/Release
33+
34+
# Dependency directories
35+
node_modules
36+
jspm_packages
37+
38+
# Optional npm cache directory
39+
.npm
40+
41+
# Optional eslint cache
42+
.eslintcache
43+
44+
# Optional REPL history
45+
.node_repl_history
46+
47+
48+
### OSX ###
49+
*.DS_Store
50+
.AppleDouble
51+
.LSOverride
52+
53+
# Icon must end with two \r
54+
Icon
55+
56+
# Thumbnails
57+
._*
58+
59+
# Files that might appear in the root of a volume
60+
.DocumentRevisions-V100
61+
.fseventsd
62+
.Spotlight-V100
63+
.TemporaryItems
64+
.Trashes
65+
.VolumeIcon.icns
66+
.com.apple.timemachine.donotpresent
67+
68+
# Directories potentially created on remote AFP share
69+
.AppleDB
70+
.AppleDesktop
71+
Network Trash Folder
72+
Temporary Items
73+
.apdisk
74+
75+
76+
### Linux ###
77+
*~
78+
79+
# temporary files which can be created if a process still has a handle open of a deleted file
80+
.fuse_hidden*
81+
82+
# KDE directory preferences
83+
.directory
84+
85+
# Linux trash folder which might appear on any partition or disk
86+
.Trash-*
87+
88+
89+
### Windows ###
90+
# Windows image file caches
91+
Thumbs.db
92+
ehthumbs.db
93+
94+
# Folder config file
95+
Desktop.ini
96+
97+
# Recycle Bin used on file shares
98+
$RECYCLE.BIN/
99+
100+
# Windows Installer files
101+
*.cab
102+
*.msi
103+
*.msm
104+
*.msp
105+
106+
# Windows shortcuts
107+
*.lnk
108+
109+
110+
### Ruby ###
111+
*.gem
112+
*.rbc
113+
/.config
114+
/coverage/
115+
/InstalledFiles
116+
/pkg/
117+
/spec/reports/
118+
/spec/examples.txt
119+
/test/tmp/
120+
/test/version_tmp/
121+
/tmp/
122+
123+
# Used by dotenv library to load environment variables.
124+
# .env
125+
126+
## Specific to RubyMotion:
127+
.dat*
128+
.repl_history
129+
build/
130+
*.bridgesupport
131+
build-iPhoneOS/
132+
build-iPhoneSimulator/
133+
134+
## Specific to RubyMotion (use of CocoaPods):
135+
#
136+
# We recommend against adding the Pods directory to your .gitignore. However
137+
# you should judge for yourself, the pros and cons are mentioned at:
138+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
139+
#
140+
# vendor/Pods/
141+
142+
## Documentation cache and generated files:
143+
/.yardoc/
144+
/_yardoc/
145+
/doc/
146+
/rdoc/
147+
148+
## Environment normalization:
149+
/.bundle/
150+
/vendor/bundle
151+
/lib/bundler/man/
152+
153+
# for a library or gem, you might want to ignore these files since the code is
154+
# intended to run in multiple environments; otherwise, check them in:
155+
# Gemfile.lock
156+
# .ruby-version
157+
# .ruby-gemset
158+
159+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
160+
.rvmrc
161+
162+
163+
### Node ###
164+
# Logs
165+
logs
166+
*.log
167+
npm-debug.log*
168+
169+
# Runtime data
170+
pids
171+
*.pid
172+
*.seed
173+
*.pid.lock
174+
175+
# Directory for instrumented libs generated by jscoverage/JSCover
176+
lib-cov
177+
178+
# Coverage directory used by tools like istanbul
179+
coverage
180+
181+
# nyc test coverage
182+
.nyc_output
183+
184+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
185+
.grunt
186+
187+
# node-waf configuration
188+
.lock-wscript
189+
190+
# Compiled binary addons (http://nodejs.org/api/addons.html)
191+
build/Release
192+
193+
# Dependency directories
194+
node_modules
195+
jspm_packages
196+
197+
# Optional npm cache directory
198+
.npm
199+
200+
# Optional eslint cache
201+
.eslintcache
202+
203+
# Optional REPL history
204+
.node_repl_history
205+
206+
207+
### Rails ###
208+
*.rbc
209+
capybara-*.html
210+
.rspec
211+
/log
212+
/tmp
213+
/db/*.sqlite3
214+
/db/*.sqlite3-journal
215+
/public/system
216+
/coverage/
217+
/spec/tmp
218+
**.orig
219+
rerun.txt
220+
pickle-email-*.html
221+
222+
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
223+
config/initializers/secret_token.rb
224+
225+
# Only include if you have production secrets in this file, which is no longer a Rails default
226+
# config/secrets.yml
227+
228+
# dotenv
229+
# TODO Comment out this rule if environment variables can be committed
230+
.env
231+
232+
## Environment normalization:
233+
/.bundle
234+
/vendor/bundle
235+
236+
# these should all be checked in to normalize the environment:
237+
# Gemfile.lock, .ruby-version, .ruby-gemset
238+
239+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
240+
.rvmrc
241+
242+
# if using bower-rails ignore default bower_components path bower.json files
243+
/vendor/assets/bower_components
244+
*.bowerrc
245+
bower.json
246+
247+
# Ignore pow environment settings
248+
.powenv
249+
250+
# Ignore Byebug command history file.
251+
.byebug_history
252+
253+
254+
#!! ERROR: express is undefined. Use list command to see defined gitignore types !!#
255+
256+
### Ember ###
257+
# see https://github.com/ember-cli/ember-cli/blob/master/blueprints/app/files/gitignore
258+
# compiled output
259+
/dist
260+
/tmp
261+
262+
# dependencies
263+
/node_modules
264+
/bower_components
265+
266+
# misc
267+
/.sass-cache
268+
/connect.lock
269+
/coverage/*
270+
/libpeerconnection.log
271+
npm-debug.log
272+
testem.log

LICENSE

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

README.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# express-api-template-oauth2
2+
3+
A template for starting projects with `express` as an API. Includes
4+
authentication and common middlewares.
5+
6+
## Dependencies
7+
8+
Install with `npm install`.
9+
10+
- [`express`](http://expressjs.com/)
11+
- [`mongoose`](http://mongoosejs.com/)
12+
13+
At the beginning of each cohort, update the versions in
14+
[`package.json`](package.json) by replace all versions with a glob (`*`) and
15+
running `npm update --save && npm update --save-dev`. You may wish to test these
16+
changes by deleting the `node_modules` directory and running `npm install`.
17+
Fix any conflicts.
18+
19+
## Installation
20+
21+
1. Click the "Use this template" button on the root page of the repository
22+
1. Replace all instances of `'express-template'` with your app name. This
23+
includes `package.json`, various debugger configurations, and the MongoDB
24+
store.
25+
1. Install dependencies with `npm install`.
26+
1. Set a SECRET_KEY in the environment (`.env` file or process manager of your choice).
27+
1. Run the API server with `npm start`. If you want your code to be reloaded on
28+
change, you should use `npm run dev` instead of
29+
`npm start`.
30+
31+
For development and testing, set the SECRET_KEY from the root of your
32+
repository using
33+
34+
```sh
35+
echo SECRET_KEY=$(/usr/local/opt/openssl/bin/openssl rand -base64 66 | tr -d '\n') >>.env
36+
```
37+
38+
39+
## Structure
40+
41+
Dependencies are stored in [`package.json`](package.json).
42+
43+
Developers should store JavaScript files in [`src/app/controllers`](src/app/controllers)
44+
and [`src/app/models`](src/app/models).
45+
46+
Routes should follow express patterns for using index.js files in folders, such as `app.use('/examples', require('./examples'))` from [`src/app/controllers/index.js`](src/app/controllers/index.js)
47+
48+
## Tasks
49+
50+
Developers should run these often!
51+
52+
- `npm run test`: Tests your code
53+
- `npm run lint:fix`: Fixes any auto-fixable issues
54+
55+
## API
56+
57+
Use the included [`openapi.yaml`](./openapi.yaml) [OAS3](https://swagger.io/docs/specification/about/) specification file to document your API in a reproduceable manner. You can even make a documentation to make this easier to read with the open-source automated reference documentation tool provided by [redoc](https://github.com/Redocly/redoc).

0 commit comments

Comments
 (0)