Skip to content

Commit a7e8b25

Browse files
author
hirsch88
committed
first commit
0 parents  commit a7e8b25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+8059
-0
lines changed

.editorconfig

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# @w3tec
2+
# http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 4
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
# Use 2 spaces since npm does not respect custom indentation settings
18+
[package.json]
19+
indent_style = space
20+
indent_size = 2

.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# @w3tec
2+
3+
# Logs #
4+
/logs
5+
*.log
6+
*.log*
7+
8+
# Node files #
9+
node_modules/
10+
bower_components/
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# OS generated files #
15+
.DS_Store
16+
Thumbs.db
17+
18+
# Typing #
19+
typings/
20+
21+
# Dist #
22+
dist/
23+
releases/
24+
25+
# Cordova #
26+
cordova/plugins/
27+
cordova/platforms/
28+
www/
29+
plugins/
30+
platforms/
31+
32+
# IDE #
33+
.idea/
34+
*.swp
35+
.awcache
36+
37+
# Generated source-code #
38+
src/**/*.js
39+
test/**/*.js
40+
coverage/
41+
42+
# Generated documentation #
43+
docs/

.travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
node_js:
3+
- "7.7.3"
4+
install:
5+
- npm run install:dev
6+
scripts:
7+
- npm test
8+
notifications:
9+
email: false

.vscode/launch.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
// Use IntelliSense to learn about possible Node.js debug attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch App",
11+
"stopOnEntry": true,
12+
"program": "${workspaceRoot}/src/index.ts",
13+
"cwd": "${workspaceRoot}",
14+
"sourceMaps": true,
15+
"preLaunchTask": "build",
16+
"env": {
17+
"NODE_ENV": "development"
18+
}
19+
}
20+
]
21+
}

.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"typescript.tsdk": "./node_modules/typescript/lib",
3+
"files.exclude": {
4+
"src/**/*.js": true,
5+
"test/**/*.js": true
6+
},
7+
"vsicons.presets.angular": false
8+
}

.vscode/tasks.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"version": "0.1.0",
3+
"command": "npm",
4+
"isShellCommand": true,
5+
"suppressTaskName": true,
6+
"tasks": [
7+
{
8+
// Build task, Cmd+Shift+B
9+
// "npm run build"
10+
"taskName": "build",
11+
"isBuildCommand": true,
12+
"args": [
13+
"run",
14+
"build"
15+
]
16+
},
17+
{
18+
// Test task, Cmd+Shift+T
19+
// "npm test"
20+
"taskName": "test",
21+
"isTestCommand": true,
22+
"args": [
23+
"test"
24+
]
25+
},
26+
{
27+
// "npm run lint"
28+
"taskName": "lint",
29+
"args": [
30+
"run",
31+
"lint"
32+
]
33+
},
34+
{
35+
// "npm run clean"
36+
"taskName": "clean",
37+
"args": [
38+
"run",
39+
"clean"
40+
]
41+
}
42+
]
43+
}

LICENSE

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

README.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Express Typescript Boilerplate
2+
3+
> Boilerplate for an restful express-apllication written in TypeScript
4+
5+
## Getting Started
6+
### Prerequisites
7+
* Install [Node.js](http://nodejs.org)
8+
* on OSX use [homebrew](http://brew.sh) `brew install node`
9+
* on Windows use [chocolatey](https://chocolatey.org/) `choco install nodejs`
10+
* Install yarn globally `npm install yarn -g`
11+
12+
## Installing
13+
* `fork` this repo
14+
* `clone` your fork
15+
* `install:dev` to install all dependencies and typings
16+
* Create new database. You will find the name in the `src/config.ts` file.
17+
* `npm run db:migrate` to create the schema
18+
* `npm run db:seed` to insert some test data
19+
* `npm run serve` to start the dev server in another tab
20+
21+
## Running the app
22+
After you have installed all dependencies you can now run the app.
23+
Run `npm run serve` to start a local server using `nodemon` which will watch for changes and then will restart the sever.
24+
The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv6, if you're using `express` server, then it's `http://[::1]:3000/`).
25+
26+
## Scripts / Commands
27+
### Install
28+
* Install all dependencies with `yarn install`
29+
* Install all typings with `npm run install:typings`
30+
* To install all dependencies and typings use `npm run install:dev`
31+
* Remove not needed libraries with `npm run install:clean`
32+
33+
### Linting
34+
* Run code analysis using `npm run lint`. This runs tshint.
35+
* There is also a vscode task for this called lint.
36+
37+
### Tests
38+
* Run the unit tests using `npm test`.
39+
* There is also a vscode task for this called test.
40+
41+
### Running in dev mode
42+
* Run `npm run serve` to start nodemon with ts-node, which will serve your app.
43+
* The server address will be displayed to you as `http://0.0.0.0:3000`
44+
45+
### Cleaning the project
46+
* Run `npm run clean` to remove all generated JavaScript files.
47+
* Run `npm run db:clean` to drop all tables of the database.
48+
49+
### Building the project and run it
50+
* Run `npm run build` to generated all JavaScript files from your TypeScript sources. After this step you can deploy the app on any server.
51+
* There is also a vscode task for this called build.
52+
* To start the builded app use `npm start`.
53+
* With `npm run zip` it will generate the JavaScript source and pack them into to a deployable zip file into the dist folder.
54+
55+
### Docs
56+
* Run `npm run docs` to generate all doc files and serve it on `http://0.0.0.0:8080`
57+
58+
### Seed
59+
* Run `npm run db:seed` to seed some data into the database
60+
61+
### Migration
62+
* Run `npm run db:migrate` to migration the new schema to the database
63+
* Run `npm run db:migrate:rollback` to rollback one version
64+
65+
66+
## Related Projects
67+
* [express-graphql-typescript-boilerplate](https://github.com/w3tecch/express-graphql-typescript-boilerplate) - A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
68+
* [aurelia-typescript-boilerplate](https://github.com/w3tecch/aurelia-typescript-boilerplate) - An Aurelia starter kit with TypeScript
69+
70+
## License
71+
MIT
72+
73+
## Documentations
74+
* [Auth0 API Documentation](https://auth0.com/docs/api/management/v2#!/Users/get_users)
75+
* [Bookshelf Cheatsheet](http://ricostacruz.com/cheatsheets/bookshelf.html)
76+
77+
---
78+
Made with ♥ by Gery Hirschfeld ([@GeryHirschfeld1](https://twitter.com/GeryHirschfeld1))

build/paths.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
/**
4+
* PATHS
5+
* Defines the app-structure of this project
6+
*/
7+
module.exports = {
8+
main: 'index.ts',
9+
src: 'src',
10+
test: 'test',
11+
docs: 'docs',
12+
dist: 'dist'
13+
};

build/tasks/build.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
'use strict';
2+
3+
const gulp = require('gulp');
4+
const path = require('path');
5+
const runSequence = require('run-sequence');
6+
const paths = require('../paths');
7+
const util = require('../util');
8+
const $ = require('gulp-load-plugins')({
9+
lazy: true
10+
});
11+
12+
let tsProjectSource, tsProjectTest;
13+
14+
gulp.task('build', (callback) => runSequence(
15+
'lint',
16+
'clean',
17+
[
18+
'build:transpile:src',
19+
'build:transpile:test'
20+
],
21+
callback
22+
));
23+
24+
gulp.task('build:transpile:src', () => transpiler(paths.src));
25+
gulp.task('build:transpile:test', () => transpiler(paths.test, true));
26+
27+
function transpiler(filePath, isTest, files) {
28+
29+
if (files === undefined) {
30+
files = '/**/*.ts';
31+
}
32+
33+
if (!tsProjectSource && !isTest) {
34+
tsProjectSource = $.typescript.createProject('tsconfig.json', {
35+
'typescript': require('typescript')
36+
});
37+
}
38+
39+
if (!tsProjectTest && isTest) {
40+
tsProjectTest = $.typescript.createProject('tsconfig.json', {
41+
'typescript': require('typescript')
42+
});
43+
}
44+
45+
let tsProject = !!isTest ? tsProjectTest : tsProjectSource;
46+
return gulp
47+
.src([
48+
'./typings/index.d.ts',
49+
'./typings_custom/**/*.d.ts',
50+
path.join(filePath, files)
51+
])
52+
.pipe($.plumber({ errorHandler: $.notify.onError('Error: <%= error.message %>') }))
53+
.pipe($.sourcemaps.init({ loadMaps: true }))
54+
.pipe(tsProject())
55+
.pipe($.sourcemaps.write()) // inline sourcemaps
56+
.pipe(gulp.dest(filePath));
57+
}

build/tasks/clean.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
const gulp = require('gulp');
4+
const path = require('path');
5+
const paths = require('../paths');
6+
const util = require('../util');
7+
const $ = require('gulp-load-plugins')({
8+
lazy: true
9+
});
10+
11+
gulp.task('clean', [
12+
'clean:docs',
13+
'clean:build'
14+
]);
15+
16+
gulp.task('clean:build', [
17+
'clean:src:src',
18+
'clean:src:map',
19+
'clean:test:src',
20+
'clean:test:map'
21+
]);
22+
23+
gulp.task('clean:docs', () => cleaner(paths.docs));
24+
gulp.task('clean:src:src', () => cleaner(paths.src, 'js'));
25+
gulp.task('clean:src:map', () => cleaner(paths.src, 'map'));
26+
gulp.task('clean:test:src', () => cleaner(paths.test, 'js'));
27+
gulp.task('clean:test:map', () => cleaner(paths.test, 'map'));
28+
29+
function cleaner(filePath, ext) {
30+
let source = '';
31+
if (ext) {
32+
source = path.join(filePath, '/**/*.' + ext);
33+
} else {
34+
source = path.join(filePath);
35+
}
36+
return gulp
37+
.src(source, {
38+
read: false
39+
})
40+
.pipe($.clean());
41+
}

build/tasks/docs.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
const gulp = require('gulp');
4+
const path = require('path');
5+
const paths = require('../paths');
6+
const util = require('../util');
7+
const $ = require('gulp-load-plugins')({
8+
lazy: true
9+
});
10+
const pkg = require('../../package.json');
11+
const tsc = require('../../tsconfig.json');
12+
13+
gulp.task('docs', ['clean:docs'], function () {
14+
return gulp
15+
.src([
16+
'./typings/index.d.ts',
17+
'./typings_custom/**/*.d.ts',
18+
path.join(paths.src, '/**/*.ts')
19+
])
20+
.pipe($.typedoc({
21+
module: tsc.compilerOptions.module,
22+
target: tsc.compilerOptions.target,
23+
moduleResolution: tsc.compilerOptions.moduleResolution,
24+
out: paths.docs,
25+
name: pkg.name
26+
}));
27+
});

0 commit comments

Comments
 (0)