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
# 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() {
// Only runs before the current describe.
before(async () => {
myhelper();
console.error('before describe 0');
});
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() {
console.error('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",
"main": "alphanumeric.js",
"dependencies": {
"mocha": "^8.3.2",
"pg": "^8.5.1",
"pg-hstore": "^2.3.3",
"sequelize": "^6.5.1"
"express": "4.17.1",
"mocha": "8.3.2",
"pg": "8.5.1",
"pg-hstore": "2.3.3",
"sequelize": "6.5.1",
"sqlite3": "^5.0.2"
},
"devDependencies": {},
"scripts": {

View File

@@ -17,11 +17,19 @@ const { Sequelize, DataTypes } = require('sequelize');
// To use the URI syntax, we need an explcit username and password.
// But the second constructor works with peer authentication.
// 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('lkmc-nodejs', undefined, undefined, {
host: '/var/run/postgresql',
dialect: 'postgres',
logging: false,
//
// Works with peer authentication:
//const sequelize = new Sequelize('lkmc-nodejs', undefined, undefined, {
// host: '/var/run/postgresql',
// dialect: 'postgres',
// logging: false,
//});
const sequelize = new Sequelize({
dialect: 'sqlite',
storage: 'tmp.sequelize.sqlite',
});
// OMG fuck this asynchronous bullshit: