Skip to content

Commit

Permalink
feat(template): fix deploy and add settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Walker Leite committed Jul 12, 2018
1 parent 940559b commit 37fef59
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ $ DEBUG=loopback npm run dev

## Executing built files

Please remember to update `server/*.production.json` files to match your enviroment.

```bash
$ cd build
$ npm run start
Expand Down
2 changes: 2 additions & 0 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ $ DEBUG=loopback npm run dev

## Executing built files

Please remember to update `server/*.production.json` files to match your enviroment.

```bash
$ cd build
$ npm run start
Expand Down
4 changes: 2 additions & 2 deletions template/client/services/loopback.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import {host, restApiRoot, port} from '~/server/config.json';
import {restApiHost, restApiRoot, port} from '~/server/config.json';
import {DateString} from 'loopback';

DateString.parse = function(dateString) {
Expand Down Expand Up @@ -35,7 +35,7 @@ function addTokenFromLocalStorage(http) {
}

const http = axios.create({
baseURL: `http://${host}:${port}${restApiRoot}`,
baseURL: `http://${restApiHost}:${port}${restApiRoot}`,
});

// Current setLoading function
Expand Down
6 changes: 0 additions & 6 deletions template/gulp-tasks/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,3 @@ dirs.testServer = path.resolve(dirs.test, 'server');
dirs.srcClient = path.resolve(dirs.root, 'client');
dirs.srcCommon = path.resolve(dirs.root, 'common');
dirs.srcServer = path.resolve(dirs.root, 'server');

// Set here production build settings
export const prod = {
host: '0.0.0.0',
port: 80,
};
5 changes: 3 additions & 2 deletions template/gulp-tasks/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import gulp from 'gulp';
import path from 'path';
import fs from 'fs';
import {argv} from 'yargs';
import {dirs, prod} from './config';
import {dirs} from './config';
import production from '../server/config.production.json';

gulp.task('copy:client:fa', () => {
return gulp
Expand Down Expand Up @@ -41,7 +42,7 @@ gulp.task('copy:config:server', ['copy:server'], (done) => {
path.resolve(dirs.buildServer, 'config.json'),
JSON.stringify({
...JSON.parse(data),
...prod,
...production,
}),
done
);
Expand Down
2 changes: 1 addition & 1 deletion template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "gulp build --production && npm run afterbuild",
"afterbuild": "cd build && npm install --production",
"test": "npx jest",
"start": "node ./index.js"
"start": "NODE_ENV=production node ."
},
"dependencies": {
"compression": "^1.0.3",
Expand Down
1 change: 1 addition & 0 deletions template/server/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"restApiRoot": "/api",
"restApiHost": "localhost",
"host": "0.0.0.0",
"port": 8000,
"remoting": {
Expand Down
4 changes: 4 additions & 0 deletions template/server/config.production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"restApiHost": "123.123.123.123",
"port": 80
}
12 changes: 12 additions & 0 deletions template/server/datasources.production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"db": {
"name": "db",
"host": "localhost",
"port": 27017,
"url": "",
"database": "databaseName",
"password": "",
"user": "",
"connector": "mongodb"
}
}

0 comments on commit 37fef59

Please sign in to comment.