dev environment

This commit is contained in:
cupcakearmy 2019-05-23 13:19:42 +02:00
parent fe8a1c8412
commit dd405d11ac
5 changed files with 20 additions and 18 deletions

View File

@ -1,11 +1,9 @@
{ {
"private": true, "private": true,
"scripts": { "scripts": {
"pkg": "tsc && pkg --targets latest-alpine-x64 --output ./server dist/server.js",
"pkg:mac": "tsc && pkg --targets latest-macos-x64 --output ./server-macos dist/server.js",
"prod": "NODE_ENV=production node dist/server.js",
"build": "tsc", "build": "tsc",
"dev": "npm i && tsnd --no-notify src/server.ts" "dev": "npm install --silent && tsnd --no-notify src/server.ts",
"prod": "NODE_ENV=production node dist/server.js"
}, },
"devDependencies": { "devDependencies": {
"@types/jsonwebtoken": "^8.3.2", "@types/jsonwebtoken": "^8.3.2",

View File

@ -15,12 +15,6 @@ import router from './routes'
createConnection({ createConnection({
type: 'sqlite', type: 'sqlite',
database: join(process.cwd(), 'db.sqlite'), database: join(process.cwd(), 'db.sqlite'),
// type: "mysql",
// host: "localhost",
// port: 3306,
// username: 'test',
// password: 'test',
// database: 'data',
entities: [User, Purchase], entities: [User, Purchase],
synchronize: true, synchronize: true,
}).then(async () => { }).then(async () => {
@ -31,7 +25,9 @@ createConnection({
await User.createOrGet(user) await User.createOrGet(user)
} }
const port = Config.get<number>('server.port') const port = process.env.NODE_ENV !== 'production'
? 5000
: 80
const server = new Koa() const server = new Koa()
server.use(responseTime) server.use(responseTime)

8
package.json Normal file
View File

@ -0,0 +1,8 @@
{
"private": true,
"scripts": {
"dev:local": "npm --prefix ./www run dev:local & npm --prefix ./api run dev",
"dev:docker": "docker-compose up",
"clean": "rm -r ./api/node_modules ./api/package-lock.json ./www/node_modules ./www/package-lock.json"
}
}

View File

@ -1,12 +1,10 @@
{ {
"private": true, "private": true,
"assets": [
".next/**/*"
],
"scripts": { "scripts": {
"dev": "npm i && node server.js", "build": "next build",
"prod": "NODE_ENV=production node server.js", "dev": "npm install --silent && node server.js",
"build": "next build" "dev:local": "npm install --silent && API_HOST=localhost node server.js",
"prod": "NODE_ENV=production node server.js"
}, },
"dependencies": { "dependencies": {
"axios": "^0.18.0", "axios": "^0.18.0",

View File

@ -12,7 +12,9 @@ const app = next({ dev })
const handle = app.getRequestHandler() const handle = app.getRequestHandler()
const proxy = httpProxy.createProxyServer() const proxy = httpProxy.createProxyServer()
const target = 'http://api' const target = dev
? `http://${process.env.API_HOST || 'api'}:5000`
: 'http://api'
app.prepare().then(() => { app.prepare().then(() => {