Skip to content

Commit

Permalink
adds boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
chrvadala committed Jan 9, 2016
1 parent 5e7d514 commit 8354aa5
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.*
!.gitignore
node_modules
npm-debug.log
/config/*.json
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# forester-boilerplate
# forester-boilerplate

## Getting started

1. Install dependencies ` $ npm install `
2. Copy `config/auth.json.dist` to `config/auth.json` and configure this file
3. Copy `config/db1.json.dist` to `config/db1.json` and configure this file
4. Start project `$ npm start`
5. Open `http://localhost:3000`

## Contributing
Your contributions (issues and pull request) are appreciated!

### License
MIT
5 changes: 5 additions & 0 deletions config/auth.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"jwt": {
"secret": "change_me"
}
}
7 changes: 7 additions & 0 deletions config/db1.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "db1",
"adapter": "mongo",
"options": {
"connectionUri": "mongodb://localhost:27017/forester"
}
}
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "forester-boilerplate",
"version": "0.0.0",
"description": "A boilerplate project based on forester",
"scripts": {
"start": "node src/server.js"
},
"dependencies": {
"forester": "^0.4.0",
"forester-auth": "^0.1.4",
"forester-explorer": "^0.1.4"
}
}
10 changes: 10 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Forester Boilerplate</title>
</head>
<body>
Hello! This is a Forester boilerplate project!
</body>
</html>
10 changes: 10 additions & 0 deletions src/sample-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";

module.exports = function (config) {

return function (forester) {
//do something with forester
console.log("sample plugin started");
};

};
43 changes: 43 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"use strict";

// libraries
const path = require('path');
const Forester = require('forester');
const foresterExplorer = require("forester-explorer");
const foresterAuth = require("forester-auth");
const samplePlugin = require("../src/sample-plugin.js");

//project items
const collections = [
require('../structure/articles.json')
];
const dataSources = [
require('../config/db1.json')
];
const mappings = require('../structure/mappings.json');
const authConfig = require('../config/auth.json');

//init forester
var app = new Forester();

//add plugins
app.use(foresterExplorer());
app.use(foresterAuth(authConfig));
app.use(samplePlugin());

//register project items
app.registerCollections(collections);
app.registerDataSources(dataSources);
app.registerMappings(mappings);

//register project public folder
app.registerStaticRoute({route: '/', failback: "index.html", path: path.join(__dirname, '../public')});

//boot
app.boot()
.then(function () {
app.listen({port: 3000});
})
.catch(function (e) {
console.log(e.stack);
});
20 changes: 20 additions & 0 deletions structure/articles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "articles",
"properties": {
"title": {
"type": "string",
"required": true
},
"description":{
"type": "string",
"default": "default description",
"required": true
}
},
"defender": [
{
"action": "*",
"check": "skip"
}
]
}
14 changes: 14 additions & 0 deletions structure/mappings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"collection": "articles",
"datasource": "db1"
},
{
"collection": "_users",
"datasource": "db1"
},
{
"collection": "_tokens",
"datasource": "db1"
}
]

0 comments on commit 8354aa5

Please sign in to comment.