-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added real typescript example && adapted .gitignore
- Loading branch information
divramod
committed
Jul 4, 2016
1 parent
1fe4883
commit f1ba04b
Showing
42 changed files
with
1,236 additions
and
932 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,51 @@ | ||
node_modules/ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
node_modules | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# ignore typings folder | ||
typings | ||
|
||
#build folder | ||
build | ||
|
||
#Ignore reports | ||
reports | ||
|
||
#vim | ||
.*.*.*.swp | ||
.*.*.swp | ||
.*.swp | ||
.*.*.*.swo | ||
.*.*.swo | ||
.*.swo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,24 @@ | ||
COMMANDS | ||
=============================================================================== | ||
```bash | ||
cd scripts | ||
nodemon runners/login.js | ||
``` | ||
|
||
Inspired By | ||
=============================================================================== | ||
- https://github.com/dwyl/hapi-typescript-example | ||
- https://github.com/poeticninja/hapi-authentication-and-authorization | ||
- https://medium.com/@poeticninja/authentication-and-authorization-with-hapi-5529b5ecc8ec#.qw0gjv67l | ||
- mongo: | ||
|
||
Test with | ||
=============================================================================== | ||
|
||
```bash | ||
# success | ||
http POST localhost:8101/login [email protected] password=admin --session=user1 | ||
|
||
# success because session is saved | ||
http localhost:8101:/example-two --session=user1 | ||
|
||
# error because no user session exists | ||
http localhost:8101:/example-two --session=user2 | ||
``` | ||
Helper | ||
=============================================================================== | ||
- https://github.com/jkbrzt/httpie | ||
- https://github.com/mafintosh/mongojs | ||
- JOI: https://github.com/hapijs/joi/blob/v8.0.5/API.md | ||
|
||
Routes | ||
=============================================================================== | ||
|
||
```bash | ||
# register | ||
http POST localhost:8101/register [email protected] forename=admin surename=admin password=pw | ||
|
||
# login | ||
http POST localhost:8101/login [email protected] password=pw | ||
|
||
# logout | ||
http localhost:8101/logout | ||
``` | ||
# typescript-node | ||
|
||
[](https://travis-ci.org/dwyl/hapi-typescript-example) | ||
|
||
This is a very simple template project for node and typescript projects. | ||
|
||
**Installation** | ||
|
||
* *npm install* (Install node packages) | ||
* *typings install* (Install typings) | ||
|
||
**Run** | ||
|
||
* *gulp build* (Build TS files) | ||
* *gulp test* (Run mocha tests) | ||
* *gulp tslint* (Run tslint) | ||
* *gulp nodemon* (Run nodemon and watch ts files) | ||
|
||
|
||
Running on port 3000 ex: localhost:3000/documentation | ||
|
||
|
||
Have fun :) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
NA: Kegelapp API | ||
MISC | ||
=============================================================================== | ||
- [ ] hapi: use payload, query, id | ||
- [ ] hapi: add cookie | ||
- [ ] hapi: http://mph-web.de/build-a-restful-api-using-hapi-js-and-mongodb/ | ||
- [ ] hapi: http://mph-web.de/social-signup-with-twitter-using-hapi-js/ | ||
- [ ] hapi: http://mph-web.de/version-your-api-with-hapi-js/``` | ||
- install mongodb on raspberry: http://andyfelong.com/2016/01/mongodb-3-0-9-binaries-for-raspberry-pi-2-jessie/ | ||
|
||
Done | ||
------------------------------------------------------------------------------- | ||
- [x] register route 2016.04.01 | ||
- [x] get mongodb running 2016.04.01 | ||
- [x] hapi add good and good-console | ||
- [x] hapi boom lib | ||
DOORS | ||
=============================================================================== | ||
x create three doors | ||
- add watcher for every door | ||
- write to mongodb when button is pressed | ||
- test if data are correctly curlable | ||
|
||
LOCATION | ||
=============================================================================== | ||
- add entity | ||
- hardware: test button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
'use strict' | ||
|
||
let gulp = require('gulp') | ||
let rimraf = require('gulp-rimraf') | ||
let tsc = require('gulp-typescript') | ||
let sourcemaps = require('gulp-sourcemaps') | ||
let tslint = require('gulp-tslint') | ||
let nodemon = require('gulp-nodemon') | ||
var mocha = require('gulp-mocha') | ||
var istanbul = require('gulp-istanbul') | ||
|
||
// /* Variables */ | ||
let tsProject = tsc.createProject('tsconfig.json') | ||
let sourceFiles = 'src/**/*.ts' | ||
let testFiles = 'test/**/*.ts' | ||
let outDir = require('./tsconfig.json').compilerOptions.outDir | ||
let entryPoint = './build/src/server.js' | ||
|
||
/** | ||
* Remove build directory. | ||
*/ | ||
gulp.task('clean', function() { | ||
return gulp.src(outDir, { read: false }) | ||
.pipe(rimraf()) | ||
}) | ||
|
||
|
||
/** | ||
* Lint all custom TypeScript files. | ||
*/ | ||
gulp.task('tslint', () => { | ||
return gulp.src(sourceFiles) | ||
.pipe(tslint()) | ||
.pipe(tslint.report('verbose')) | ||
}) | ||
|
||
/** | ||
* Compile TypeScript sources and create sourcemaps in build directory. | ||
*/ | ||
gulp.task('compile', ['clean'], () => { | ||
let tsResult = gulp.src([sourceFiles, testFiles]) | ||
.pipe(sourcemaps.init()) | ||
.pipe(tsc(tsProject)) | ||
return tsResult.js | ||
.pipe(sourcemaps.write('.')) | ||
.pipe(gulp.dest(outDir)) | ||
}) | ||
|
||
/** | ||
* Watch for changes in TypeScript, HTML and CSS files. | ||
*/ | ||
gulp.task('watch', function() { | ||
gulp.watch([sourceFiles], ['compile']).on('change', (e) => { | ||
console.log('TypeScript file ' + e.path + ' has been changed. Compiling.') | ||
}) | ||
}) | ||
|
||
/** | ||
* Build the project. | ||
*/ | ||
gulp.task('build', ['compile'], () => { | ||
console.log('Building the project ...') | ||
}) | ||
|
||
gulp.task('test', ['build'], () => { | ||
return gulp.src(['build/test/**/*.js'], { read: false }) | ||
.pipe(mocha({ reporter: 'list' })) | ||
.once('error', () => { | ||
process.exit(1); | ||
}) | ||
.once('end', () => { | ||
process.exit(); | ||
}); | ||
}) | ||
|
||
|
||
gulp.task('nodemon', ['build'], () => { | ||
nodemon({ | ||
script: entryPoint, | ||
env: { 'NODE_ENV': 'development' }, | ||
tasks: [] | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,57 @@ | ||
{ | ||
"name": "hapi-authentication-and-authorization", | ||
"description": "Example using hapi for auth", | ||
"version": "0.0.1", | ||
"author": "Saul Maddox", | ||
"private": false, | ||
"main": "server.js", | ||
"engines": { | ||
"node": "v5.0.0" | ||
"name": "new-folder", | ||
"version": "1.0.0", | ||
"description": "", | ||
"license": "MIT", | ||
"repository": { | ||
"url": "https://github.com/Talento90/typescript-node.git" | ||
}, | ||
"author": "Talento90", | ||
"keywords": [ | ||
"typescript", | ||
"project structure", | ||
"gulp", | ||
"nodejs" | ||
], | ||
"scripts": { | ||
"start": "node server.js" | ||
"test": "gulp test", | ||
"start": "gulp nodemon", | ||
"build": "gulp build", | ||
"tslint": "gulp tslint", | ||
"postinstall": "npm run typings-install", | ||
"typings-install": "typings install" | ||
}, | ||
"dependencies": { | ||
"bluebird": "^2.9.25", | ||
"boom": "~2.7.1", | ||
"colors": "^1.1.2", | ||
"good": "~6.1.2", | ||
"good-console": "~5.0.0", | ||
"hapi": "~8.6.1", | ||
"hapi-auth-cookie": "~2.2.0", | ||
"hapi-auth-jwt2": "^5.8.0", | ||
"joi": "~7.0.0", | ||
"jsonwebtoken": "^5.7.0", | ||
"mongojs": "^2.3.0", | ||
"node-uuid": "^1.4.7" | ||
"boom": "^3.0.0", | ||
"fs": "0.0.2", | ||
"good": "^6.6.0", | ||
"good-console": "^5.3.1", | ||
"hapi": "^13.0.0", | ||
"hapi-swagger": "^4.2.1", | ||
"inert": "^3.2.0", | ||
"joi": "^7.0.1", | ||
"moment": "^2.12.0", | ||
"mongodb": "^2.1.7", | ||
"node-uuid": "^1.4.7", | ||
"onoff": "^1.1.0", | ||
"path": "^0.12.7", | ||
"vision": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"co": "^4.6.0", | ||
"mongodb": "^2.1.16" | ||
"chai": "^3.5.0", | ||
"gulp": "^3.9.0", | ||
"gulp-help": "^1.6.0", | ||
"gulp-istanbul": "^0.10.3", | ||
"gulp-mocha": "^2.1.3", | ||
"gulp-nodemon": "^2.0.4", | ||
"gulp-rimraf": "^0.2.0", | ||
"gulp-sourcemaps": "^1.6.0", | ||
"gulp-tslint": "^3.1", | ||
"gulp-typescript": "^2.8.3", | ||
"tslint": "^3.5.0", | ||
"typescript": "^1.7.3" | ||
}, | ||
"engines": { | ||
"node": ">=4.1.1" | ||
} | ||
} |
Oops, something went wrong.