Express boilerplate

This commit is contained in:
Clément GOUIN
2019-06-19 10:36:45 +02:00
parent db03535ee9
commit f170b4c3ea
8 changed files with 9886 additions and 13 deletions
+4 -2
View File
@@ -1,2 +1,4 @@
.idea /.idea
node_modules /node_modules
/config.json
/data
+24
View File
@@ -0,0 +1,24 @@
{
"esversion": 6,
"maxerr": 999,
"indent": true,
"camelcase": true,
"eqeqeq": true,
"forin": true,
"immed": true,
"latedef": true,
"noarg": true,
"noempty": true,
"nonew": true,
"undef": true,
"unused": true,
"varstmt": true,
"sub": true,
"quotmark": "single",
"browser": true,
"jquery": true,
"devel": true,
"node": true,
"globals": {
}
}
+23 -11
View File
@@ -14,9 +14,10 @@ A static blog using Markdown pulled from your git repository.
![rss](./uml/rss.png) ![rss](./uml/rss.png)
## Installation ## Installation
**1. Download the latest version from the repo** **1. Download and install the latest version from the repo**
```bash ```bash
git clone https://github.com/klemek/gitblog.md.git git clone https://github.com/klemek/gitblog.md.git
npm install
``` ```
**2. Create your config file** **2. Create your config file**
```bash ```bash
@@ -27,13 +28,13 @@ then edit the config.json file with your values :
> default values for config.json > default values for config.json
````json ````json
{ {
"node_port": 3000, "nodePort": 3000,
"data_dir": "data", "dataDir": "data",
"modules" : { "modules" : {
"plantuml" : true, "plantuml" : true,
"rss": true, "rss": true,
"webhook": true "webhook": true
}, },
"home" : { "home" : {
"index" : "index.ejs" "index" : "index.ejs"
}, },
@@ -41,16 +42,27 @@ then edit the config.json file with your values :
"index" : "index.md" "index" : "index.md"
}, },
"rss" : { "rss" : {
"endpoint" : "/rss", "endpoint" : "/rss",
"length" : 10 "length" : 10
}, },
"webhook" : { "webhook" : {
"endpoint": "/webhook", "endpoint": "/webhook",
"secret_file": "git_secret" "secretFile": "git_secret"
} }
} }
```` ````
**3. Create and init your git source**
**3. Start your server**
```bash
npm start
#or
node server.js
```
This might want to use something like screen to separate the process from your current terminal session.
**4. Create and init your git source**
You need to [create a new repository](https://github.com/new) on your favorite Git service. You need to [create a new repository](https://github.com/new) on your favorite Git service.
@@ -61,7 +73,7 @@ git remote add origin <url_of_your_repo.git>
git push -u origin master git push -u origin master
``` ```
**4. Refresh content with a webhook (optional)** **5. Refresh content with a webhook (optional)**
At first start, a `git_secret` file will be generated, use it to create a new webhook as following : At first start, a `git_secret` file will be generated, use it to create a new webhook as following :
+12
View File
@@ -0,0 +1,12 @@
const express = require('express');
const app = express();
module.exports = function(/*config*/){
app.get('/', (req,res) => {
res.status(200).send('Hello World!');
});
return app;
};
+23
View File
@@ -0,0 +1,23 @@
{
"nodePort": 3000,
"dataDir": "data",
"modules" : {
"plantuml" : true,
"rss": true,
"webhook": true
},
"home" : {
"index" : "index.ejs"
},
"article" : {
"index" : "index.md"
},
"rss" : {
"endpoint" : "/rss",
"length" : 10
},
"webhook" : {
"endpoint": "/webhook",
"secretFile": "git_secret"
}
}
+9758
View File
File diff suppressed because it is too large Load Diff
+33
View File
@@ -0,0 +1,33 @@
{
"name": "gitblog.md",
"version": "1.0.0",
"description": "A static blog using Markdown pulled from your git repository.",
"main": "server.js",
"dependencies": {
"express": "^4.17.1",
"ncp": "^2.0.0",
"node-plantuml": "^0.8.1",
"showdown": "^1.9.0",
"xml": "^1.0.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"jest": "^24.8.0",
"superagent": "^5.1.0",
"supertest": "^4.0.2"
},
"scripts": {
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/klemek/gitblog.md.git"
},
"author": "klemek",
"license": "ISC",
"bugs": {
"url": "https://github.com/klemek/gitblog.md/issues"
},
"homepage": "https://github.com/klemek/gitblog.md#readme"
}
+9
View File
@@ -0,0 +1,9 @@
const config = require('./config.json');
const app = require('./app')(config);
const port = config.nodePort|3000;
app.listen(config.nodePort|3000, () => {
console.log(`gitblog.md server listening on port ${port}`);
});