sequelize sqlite

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2021-04-20 01:00:00 +00:00
parent 461aa04b8b
commit 64e8add2b8
7 changed files with 1287 additions and 11 deletions

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env node
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})

View File

@@ -1,3 +1,3 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Run mocha tests. # Run mocha tests.
npx mocha --require mocha_tests/global.js mocha_tests npx mocha --require mocha/utils.js mocha

View File

@@ -3,7 +3,6 @@ var assert = require('assert');
describe('describe0', function() { describe('describe0', function() {
// Only runs before the current describe. // Only runs before the current describe.
before(async () => { before(async () => {
myhelper();
console.error('before describe 0'); console.error('before describe 0');
}); });
beforeEach(async () => { beforeEach(async () => {

View File

@@ -15,8 +15,9 @@ exports.mochaHooks = {
}, },
}; };
// TODO don't know a better way to make this available
// to test files than just requiring it by relative path.
function myhelper() { function myhelper() {
console.error('myhelper'); console.error('myhelper');
} }
exports.myhelper = myhelper; exports.myhelper = myhelper;

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,12 @@
"description": "https://cirosantilli.com/linux-kernel-module-cheat#node-js", "description": "https://cirosantilli.com/linux-kernel-module-cheat#node-js",
"main": "alphanumeric.js", "main": "alphanumeric.js",
"dependencies": { "dependencies": {
"mocha": "^8.3.2", "express": "4.17.1",
"pg": "^8.5.1", "mocha": "8.3.2",
"pg-hstore": "^2.3.3", "pg": "8.5.1",
"sequelize": "^6.5.1" "pg-hstore": "2.3.3",
"sequelize": "6.5.1",
"sqlite3": "^5.0.2"
}, },
"devDependencies": {}, "devDependencies": {},
"scripts": { "scripts": {

View File

@@ -17,11 +17,19 @@ const { Sequelize, DataTypes } = require('sequelize');
// To use the URI syntax, we need an explcit username and password. // To use the URI syntax, we need an explcit username and password.
// But the second constructor works with peer authentication. // But the second constructor works with peer authentication.
// https://stackoverflow.com/questions/46207155/sequelize-and-peer-authentication-for-postgres // https://stackoverflow.com/questions/46207155/sequelize-and-peer-authentication-for-postgres
//
// Fails
//const sequelize = new Sequelize('postgres://user:password@localhost:5432/lkmc-nodejs') //const sequelize = new Sequelize('postgres://user:password@localhost:5432/lkmc-nodejs')
const sequelize = new Sequelize('lkmc-nodejs', undefined, undefined, { //
host: '/var/run/postgresql', // Works with peer authentication:
dialect: 'postgres', //const sequelize = new Sequelize('lkmc-nodejs', undefined, undefined, {
logging: false, // host: '/var/run/postgresql',
// dialect: 'postgres',
// logging: false,
//});
const sequelize = new Sequelize({
dialect: 'sqlite',
storage: 'tmp.sequelize.sqlite',
}); });
// OMG fuck this asynchronous bullshit: // OMG fuck this asynchronous bullshit: