@alchemycodelab/create-app
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -1,7 +0,7 @@ | ||
const pool = require('../lib/utils/pool'); | ||
const setup = require('../data/setup'); | ||
const request = require('supertest'); | ||
const app = require('../lib/app'); | ||
import pool from '../lib/utils/pool.js'; | ||
import setup from '../data/setup.js'; | ||
import request from 'supertest'; | ||
import app from '../lib/app.js'; | ||
describe('{{appName}} routes', () => { | ||
describe('demo routes', () => { | ||
beforeEach(() => { | ||
@@ -8,0 +8,0 @@ return setup(pool); |
@@ -1,6 +0,13 @@ | ||
const fs = require('fs').promises; | ||
import { promises as fs } from 'fs'; | ||
import path from 'path'; | ||
module.exports = (pool) => { | ||
return fs.readFile(`${__dirname}/../sql/setup.sql`, { encoding: 'utf-8' }) | ||
.then(sql => pool.query(sql)); | ||
export default (pool) => { | ||
return fs | ||
.readFile( | ||
`${path.dirname(new URL(import.meta.url).pathname)}/../sql/setup.sql`, | ||
{ | ||
encoding: 'utf-8', | ||
} | ||
) | ||
.then((sql) => pool.query(sql)); | ||
}; |
@@ -1,2 +0,5 @@ | ||
const express = require('express'); | ||
import express from 'express'; | ||
import notFoundMiddleware from './middleware/not-found.js'; | ||
import errorMiddleware from './middleware/error.js'; | ||
const app = express(); | ||
@@ -6,5 +9,9 @@ | ||
app.use(require('./middleware/not-found')); | ||
app.use(require('./middleware/error')); | ||
if (app) { | ||
console.log('hi'); | ||
} | ||
module.exports = app; | ||
app.use(notFoundMiddleware); | ||
app.use(errorMiddleware); | ||
export default app; |
// eslint-disable-next-line no-unused-vars | ||
module.exports = (err, req, res, next) => { | ||
export default (err, req, res, next) => { | ||
let status = err.status || 500; | ||
@@ -4,0 +4,0 @@ |
@@ -1,2 +0,2 @@ | ||
module.exports = (req, res, next) => { | ||
export default (req, res, next) => { | ||
const err = new Error('Not Found'); | ||
@@ -3,0 +3,0 @@ err.status = 404; |
@@ -1,6 +0,6 @@ | ||
const { Pool } = require('pg'); | ||
import pg from 'pg'; | ||
const pool = new Pool({ | ||
const pool = new pg.Pool({ | ||
connectionString: process.env.DATABASE_URL, | ||
ssl: process.env.PGSSLMODE && { rejectUnauthorized: false } | ||
ssl: process.env.PGSSLMODE && { rejectUnauthorized: false }, | ||
}); | ||
@@ -10,2 +10,2 @@ | ||
module.exports = pool; | ||
export default pool; |
@@ -1,3 +0,3 @@ | ||
const app = require('./lib/app'); | ||
const pool = require('./lib/utils/pool'); | ||
import app from './lib/app.js'; | ||
import pool from './lib/utils/pool.js'; | ||
@@ -4,0 +4,0 @@ const PORT = process.env.PORT || 7890; |
@@ -1,4 +0,4 @@ | ||
const pool = require('./lib/utils/pool'); | ||
const setup = require('./data/setup'); | ||
import pool from './lib/utils/pool.js'; | ||
import setup from './data/setup.js'; | ||
setup(pool); |
{ | ||
"name": "@alchemycodelab/create-app", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
387
20213