-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add console #2
base: main
Are you sure you want to change the base?
Add console #2
Conversation
I wanted to start a console with our app loaded for easier debugging of stuffs. To do this I need app to be available for export without starting the server. This commit moves the app definition into its own file which can be required separately
This is a command that will start a REPL. The app can be loaded into the repl context with: import('<path to app.js>')
import sqlite from 'sqlite3' | ||
import ejs from 'ejs' | ||
|
||
const db = new sqlite.Database('../db.sqlite') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy has a fix for the issue: Replace '../db.sqlite')
with "../db.sqlite");
const db = new sqlite.Database('../db.sqlite') | |
const db = new sqlite.Database("../db.sqlite"); |
app.listen(port, function() { | ||
console.log(`Listening on port ${port}`) | ||
}) | ||
|
||
db.close() | ||
app.db.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy has a fix for the issue: Insert ;
app.db.close() | |
app.db.close(); |
response.render('index') | ||
}) | ||
|
||
export default app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy has a fix for the issue: Insert ;
export default app | |
export default app; |
|
||
app.db = db | ||
|
||
app.set('view engine', 'ejs') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy has a fix for the issue: Replace 'view·engine',·'ejs')
with "view·engine",·"ejs");
app.set('view engine', 'ejs') | |
app.set("view engine", "ejs"); |
|
||
const app = express() | ||
|
||
app.db = db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy has a fix for the issue: Insert ;
app.db = db | |
app.db = db; |
@@ -0,0 +1,6 @@ | |||
import repl from 'repl' | |||
import app from '../src/app.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy has a fix for the issue: Replace '../src/app.js'
with "../src/app.js";
import app from '../src/app.js' | |
import app from "../src/app.js"; |
@@ -0,0 +1,18 @@ | |||
import cors from 'express' | |||
import express from 'express' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy has a fix for the issue: Replace 'express'
with "express";
import express from 'express' | |
import express from "express"; |
@@ -0,0 +1,6 @@ | |||
import repl from 'repl' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy has a fix for the issue: Replace 'repl'
with "repl";
import repl from 'repl' | |
import repl from "repl"; |
I wanted to start a console with our app loaded for easier debugging of
stuffs.
To do this I need app to be available for export without starting the
server.
The app can now be started in a repl consol locally with
yarn console
.The app object is made available to the local context