mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 14:25:38 -04:00
Merge pull request #355 from davidmehren/tests-in-typescript
Migrate tests to typescript
This commit is contained in:
commit
7fe44cb867
14 changed files with 354 additions and 378 deletions
|
@ -6,9 +6,9 @@
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run-script eslint && npm run-script jsonlint && npm run-script mocha-suite",
|
"test": "npm run-script eslint && npm run-script jsonlint && npm run-script mocha-suite",
|
||||||
"eslint": "node_modules/.bin/eslint --max-warnings 0 src",
|
"eslint": "node_modules/.bin/eslint --ext .ts,.js --max-warnings 0 src",
|
||||||
"jsonlint": "find . -not -path './node_modules/*' -type f -name '*.json' -o -type f -name '*.json.example' | while read json; do echo $json ; jq . $json; done",
|
"jsonlint": "find . -not -path './node_modules/*' -type f -name '*.json' -o -type f -name '*.json.example' | while read json; do echo $json ; jq . $json; done",
|
||||||
"mocha-suite": "NODE_ENV=test CMD_DB_URL=\"sqlite::memory:\" mocha --exit",
|
"mocha-suite": "tsc && NODE_ENV=test CMD_DB_URL=\"sqlite::memory:\" mocha --exit built/test/*.js",
|
||||||
"standard": "echo 'standard is no longer being used, use `npm run eslint` instead!' && exit 1",
|
"standard": "echo 'standard is no longer being used, use `npm run eslint` instead!' && exit 1",
|
||||||
"dev": "webpack --config webpack.dev.js --progress --colors --watch",
|
"dev": "webpack --config webpack.dev.js --progress --colors --watch",
|
||||||
"heroku-prebuild": "bin/heroku",
|
"heroku-prebuild": "bin/heroku",
|
||||||
|
@ -175,6 +175,7 @@
|
||||||
"@types/helmet": "^0.0.45",
|
"@types/helmet": "^0.0.45",
|
||||||
"@types/lodash": "^4.14.149",
|
"@types/lodash": "^4.14.149",
|
||||||
"@types/minio": "^7.0.5",
|
"@types/minio": "^7.0.5",
|
||||||
|
"@types/mocha": "^7.0.2",
|
||||||
"@types/node": "^13.11.1",
|
"@types/node": "^13.11.1",
|
||||||
"@types/passport": "^1.0.3",
|
"@types/passport": "^1.0.3",
|
||||||
"@types/passport-facebook": "^2.1.9",
|
"@types/passport-facebook": "^2.1.9",
|
||||||
|
@ -186,6 +187,7 @@
|
||||||
"@types/passport-twitter": "^1.0.34",
|
"@types/passport-twitter": "^1.0.34",
|
||||||
"@types/passport.socketio": "^3.7.2",
|
"@types/passport.socketio": "^3.7.2",
|
||||||
"@types/randomcolor": "^0.5.4",
|
"@types/randomcolor": "^0.5.4",
|
||||||
|
"@types/sinon": "^9.0.0",
|
||||||
"@types/validator": "^13.0.0",
|
"@types/validator": "^13.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.27.0",
|
"@typescript-eslint/eslint-plugin": "^2.27.0",
|
||||||
"@typescript-eslint/parser": "^2.27.0",
|
"@typescript-eslint/parser": "^2.27.0",
|
||||||
|
@ -214,11 +216,12 @@
|
||||||
"less-loader": "^5.0.0",
|
"less-loader": "^5.0.0",
|
||||||
"mini-css-extract-plugin": "^0.8.0",
|
"mini-css-extract-plugin": "^0.8.0",
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0",
|
||||||
"mock-require": "^3.0.3",
|
|
||||||
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
||||||
"script-loader": "^0.7.2",
|
"script-loader": "^0.7.2",
|
||||||
|
"sinon": "^9.0.2",
|
||||||
"string-loader": "^0.0.1",
|
"string-loader": "^0.0.1",
|
||||||
"style-loader": "^1.0.0",
|
"style-loader": "^1.0.0",
|
||||||
|
"ts-mock-imports": "^1.3.0",
|
||||||
"ts-node": "^8.8.2",
|
"ts-node": "^8.8.2",
|
||||||
"typescript": "^3.7.2",
|
"typescript": "^3.7.2",
|
||||||
"url-loader": "^2.3.0",
|
"url-loader": "^2.3.0",
|
||||||
|
|
|
@ -21,6 +21,8 @@ const debugConfig = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get version string from package.json
|
// Get version string from package.json
|
||||||
|
// TODO: There are other ways to geht the current version
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const { version, repository } = require(path.join(appRootPath, 'package.json'))
|
const { version, repository } = require(path.join(appRootPath, 'package.json'))
|
||||||
|
|
||||||
const commitID = getGitCommit(appRootPath)
|
const commitID = getGitCommit(appRootPath)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const config = require('./config')
|
import { config } from './config'
|
||||||
|
|
||||||
function responseError (res, code: number, detail: string, msg: string): void {
|
function responseError (res, code: number, detail: string, msg: string): void {
|
||||||
res.status(code).render('error.ejs', {
|
res.status(code).render('error.ejs', {
|
||||||
|
|
1
src/lib/library-ext.d.ts
vendored
1
src/lib/library-ext.d.ts
vendored
|
@ -1,6 +1,5 @@
|
||||||
import { User } from './models'
|
import { User } from './models'
|
||||||
|
|
||||||
|
|
||||||
declare module 'express' {
|
declare module 'express' {
|
||||||
export interface Request {
|
export interface Request {
|
||||||
user?: User;
|
user?: User;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import fs from 'fs'
|
||||||
|
|
||||||
import { logger } from './logger'
|
import { logger } from './logger'
|
||||||
|
|
||||||
import { NoteUtils } from './web/note/util'
|
import * as NoteUtils from './web/note/util'
|
||||||
|
|
||||||
import { errors } from './errors'
|
import { errors } from './errors'
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@ import passport from 'passport'
|
||||||
import LDAPStrategy from 'passport-ldapauth'
|
import LDAPStrategy from 'passport-ldapauth'
|
||||||
|
|
||||||
import { config } from '../../../config'
|
import { config } from '../../../config'
|
||||||
import { User } from '../../../models'
|
|
||||||
import { logger } from '../../../logger'
|
|
||||||
import { urlencodedParser } from '../../utils'
|
|
||||||
import { errors } from '../../../errors'
|
import { errors } from '../../../errors'
|
||||||
|
import { logger } from '../../../logger'
|
||||||
|
import { User } from '../../../models'
|
||||||
|
import { urlencodedParser } from '../../utils'
|
||||||
import { AuthMiddleware } from '../interface'
|
import { AuthMiddleware } from '../interface'
|
||||||
|
|
||||||
export const LdapMiddleware: AuthMiddleware = {
|
export const LdapMiddleware: AuthMiddleware = {
|
||||||
|
@ -22,7 +22,7 @@ export const LdapMiddleware: AuthMiddleware = {
|
||||||
searchFilter: config.ldap.searchFilter || null,
|
searchFilter: config.ldap.searchFilter || null,
|
||||||
searchAttributes: config.ldap.searchAttributes || null,
|
searchAttributes: config.ldap.searchAttributes || null,
|
||||||
tlsOptions: config.ldap.tlsOptions || null,
|
tlsOptions: config.ldap.tlsOptions || null,
|
||||||
starttls: config.ldap.starttls || null
|
starttls: config.ldap.starttls || null
|
||||||
}
|
}
|
||||||
}, function (user, done) {
|
}, function (user, done) {
|
||||||
let uuid = user.uidNumber || user.uid || user.sAMAccountName || undefined
|
let uuid = user.uidNumber || user.uid || user.sAMAccountName || undefined
|
||||||
|
|
|
@ -1,140 +1,138 @@
|
||||||
import { NextFunction, Request, Response } from 'express'
|
import { NextFunction, Request, Response } from 'express'
|
||||||
import { NoteUtils } from './util'
|
|
||||||
import * as ActionController from './actions'
|
|
||||||
import { errors } from '../../errors'
|
|
||||||
import { config } from '../../config'
|
import { config } from '../../config'
|
||||||
|
import { errors } from '../../errors'
|
||||||
import { logger } from '../../logger'
|
import { logger } from '../../logger'
|
||||||
import { User, Note } from '../../models'
|
import { Note, User } from '../../models'
|
||||||
|
import * as ActionController from './actions'
|
||||||
|
import * as NoteUtils from './util'
|
||||||
|
|
||||||
export module NoteController {
|
export function publishNoteActions (req: any, res: Response, next: NextFunction) {
|
||||||
export function publishNoteActions (req: any, res: Response, next: NextFunction) {
|
NoteUtils.findNoteOrCreate(req, res, function (note) {
|
||||||
NoteUtils.findNoteOrCreate(req, res, function (note) {
|
const action = req.params.action
|
||||||
const action = req.params.action
|
switch (action) {
|
||||||
switch (action) {
|
case 'download':
|
||||||
case 'download':
|
exports.downloadMarkdown(req, res, note)
|
||||||
exports.downloadMarkdown(req, res, note)
|
break
|
||||||
break
|
case 'edit':
|
||||||
case 'edit':
|
res.redirect(config.serverURL + '/' + (note.alias ? note.alias : Note.encodeNoteId(note.id)) + '?both')
|
||||||
res.redirect(config.serverURL + '/' + (note.alias ? note.alias : Note.encodeNoteId(note.id)) + '?both')
|
break
|
||||||
break
|
default:
|
||||||
default:
|
res.redirect(config.serverURL + '/s/' + note.shortid)
|
||||||
res.redirect(config.serverURL + '/s/' + note.shortid)
|
break
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function showPublishNote (req: any, res: Response, next: NextFunction) {
|
|
||||||
const include = [{
|
|
||||||
model: User,
|
|
||||||
as: 'owner'
|
|
||||||
}, {
|
|
||||||
model: User,
|
|
||||||
as: 'lastchangeuser'
|
|
||||||
}]
|
|
||||||
NoteUtils.findNoteOrCreate(req, res, function (note) {
|
|
||||||
// force to use short id
|
|
||||||
const shortid = req.params.shortid
|
|
||||||
if ((note.alias && shortid !== note.alias) || (!note.alias && shortid !== note.shortid)) {
|
|
||||||
return res.redirect(config.serverURL + '/s/' + (note.alias || note.shortid))
|
|
||||||
}
|
|
||||||
note.increment('viewcount').then(function (note) {
|
|
||||||
if (!note) {
|
|
||||||
return errors.errorNotFound(res)
|
|
||||||
}
|
|
||||||
NoteUtils.getPublishData(req, res, note, (data) => {
|
|
||||||
res.set({
|
|
||||||
'Cache-Control': 'private' // only cache by client
|
|
||||||
})
|
|
||||||
return res.render('pretty.ejs', data)
|
|
||||||
})
|
|
||||||
}).catch(function (err) {
|
|
||||||
logger.error(err)
|
|
||||||
return errors.errorInternalError(res)
|
|
||||||
})
|
|
||||||
}, include)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function showNote (req: any, res: Response, next: NextFunction) {
|
|
||||||
NoteUtils.findNoteOrCreate(req, res, function (note) {
|
|
||||||
// force to use note id
|
|
||||||
const noteId = req.params.noteId
|
|
||||||
const id = Note.encodeNoteId(note.id)
|
|
||||||
if ((note.alias && noteId !== note.alias) || (!note.alias && noteId !== id)) {
|
|
||||||
return res.redirect(config.serverURL + '/' + (note.alias || id))
|
|
||||||
}
|
|
||||||
const body = note.content
|
|
||||||
const extracted = Note.extractMeta(body)
|
|
||||||
const meta = Note.parseMeta(extracted.meta)
|
|
||||||
let title = Note.decodeTitle(note.title)
|
|
||||||
title = Note.generateWebTitle(meta.title || title)
|
|
||||||
const opengraph = Note.parseOpengraph(meta, title)
|
|
||||||
res.set({
|
|
||||||
'Cache-Control': 'private', // only cache by client
|
|
||||||
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
|
|
||||||
})
|
|
||||||
return res.render('codimd.ejs', {
|
|
||||||
title: title,
|
|
||||||
opengraph: opengraph
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createFromPOST (req: any, res: Response, next: NextFunction) {
|
|
||||||
let body = ''
|
|
||||||
if (req.body && req.body.length > config.documentMaxLength) {
|
|
||||||
return errors.errorTooLong(res)
|
|
||||||
} else if (req.body) {
|
|
||||||
body = req.body
|
|
||||||
}
|
}
|
||||||
body = body.replace(/[\r]/g, '')
|
})
|
||||||
return NoteUtils.newNote(req, res, body)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export function doAction (req: any, res: Response, next: NextFunction) {
|
export function showPublishNote (req: any, res: Response, next: NextFunction) {
|
||||||
const noteId = req.params.noteId
|
const include = [{
|
||||||
NoteUtils.findNoteOrCreate(req, res, (note) => {
|
model: User,
|
||||||
const action = req.params.action
|
as: 'owner'
|
||||||
// TODO: Don't switch on action, choose action in Router and use separate functions
|
}, {
|
||||||
switch (action) {
|
model: User,
|
||||||
case 'publish':
|
as: 'lastchangeuser'
|
||||||
case 'pretty': // pretty deprecated
|
}]
|
||||||
res.redirect(config.serverURL + '/s/' + (note.alias || note.shortid))
|
NoteUtils.findNoteOrCreate(req, res, function (note) {
|
||||||
break
|
// force to use short id
|
||||||
case 'slide':
|
const shortid = req.params.shortid
|
||||||
res.redirect(config.serverURL + '/p/' + (note.alias || note.shortid))
|
if ((note.alias && shortid !== note.alias) || (!note.alias && shortid !== note.shortid)) {
|
||||||
break
|
return res.redirect(config.serverURL + '/s/' + (note.alias || note.shortid))
|
||||||
case 'download':
|
}
|
||||||
exports.downloadMarkdown(req, res, note)
|
note.increment('viewcount').then(function (note) {
|
||||||
break
|
if (!note) {
|
||||||
case 'info':
|
return errors.errorNotFound(res)
|
||||||
ActionController.getInfo(req, res, note)
|
|
||||||
break
|
|
||||||
case 'gist':
|
|
||||||
ActionController.createGist(req, res, note)
|
|
||||||
break
|
|
||||||
case 'revision':
|
|
||||||
ActionController.getRevision(req, res, note)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
return res.redirect(config.serverURL + '/' + noteId)
|
|
||||||
}
|
}
|
||||||
|
NoteUtils.getPublishData(req, res, note, (data) => {
|
||||||
|
res.set({
|
||||||
|
'Cache-Control': 'private' // only cache by client
|
||||||
|
})
|
||||||
|
return res.render('pretty.ejs', data)
|
||||||
|
})
|
||||||
|
}).catch(function (err) {
|
||||||
|
logger.error(err)
|
||||||
|
return errors.errorInternalError(res)
|
||||||
})
|
})
|
||||||
}
|
}, include)
|
||||||
|
}
|
||||||
|
|
||||||
export function downloadMarkdown (req: Request, res: Response, note: any) {
|
export function showNote (req: any, res: Response, next: NextFunction) {
|
||||||
|
NoteUtils.findNoteOrCreate(req, res, function (note) {
|
||||||
|
// force to use note id
|
||||||
|
const noteId = req.params.noteId
|
||||||
|
const id = Note.encodeNoteId(note.id)
|
||||||
|
if ((note.alias && noteId !== note.alias) || (!note.alias && noteId !== id)) {
|
||||||
|
return res.redirect(config.serverURL + '/' + (note.alias || id))
|
||||||
|
}
|
||||||
const body = note.content
|
const body = note.content
|
||||||
let filename = Note.decodeTitle(note.title)
|
const extracted = Note.extractMeta(body)
|
||||||
filename = encodeURIComponent(filename)
|
const meta = Note.parseMeta(extracted.meta)
|
||||||
|
let title = Note.decodeTitle(note.title)
|
||||||
|
title = Note.generateWebTitle(meta.title || title)
|
||||||
|
const opengraph = Note.parseOpengraph(meta, title)
|
||||||
res.set({
|
res.set({
|
||||||
'Access-Control-Allow-Origin': '*', // allow CORS as API
|
'Cache-Control': 'private', // only cache by client
|
||||||
'Access-Control-Allow-Headers': 'Range',
|
|
||||||
'Access-Control-Expose-Headers': 'Cache-Control, Content-Encoding, Content-Range',
|
|
||||||
'Content-Type': 'text/markdown; charset=UTF-8',
|
|
||||||
'Cache-Control': 'private',
|
|
||||||
'Content-disposition': 'attachment; filename=' + filename + '.md',
|
|
||||||
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
|
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
|
||||||
})
|
})
|
||||||
res.send(body)
|
return res.render('codimd.ejs', {
|
||||||
}
|
title: title,
|
||||||
|
opengraph: opengraph
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createFromPOST (req: any, res: Response, next: NextFunction) {
|
||||||
|
let body = ''
|
||||||
|
if (req.body && req.body.length > config.documentMaxLength) {
|
||||||
|
return errors.errorTooLong(res)
|
||||||
|
} else if (req.body) {
|
||||||
|
body = req.body
|
||||||
|
}
|
||||||
|
body = body.replace(/[\r]/g, '')
|
||||||
|
return NoteUtils.newNote(req, res, body)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function doAction (req: any, res: Response, next: NextFunction) {
|
||||||
|
const noteId = req.params.noteId
|
||||||
|
NoteUtils.findNoteOrCreate(req, res, (note) => {
|
||||||
|
const action = req.params.action
|
||||||
|
// TODO: Don't switch on action, choose action in Router and use separate functions
|
||||||
|
switch (action) {
|
||||||
|
case 'publish':
|
||||||
|
case 'pretty': // pretty deprecated
|
||||||
|
res.redirect(config.serverURL + '/s/' + (note.alias || note.shortid))
|
||||||
|
break
|
||||||
|
case 'slide':
|
||||||
|
res.redirect(config.serverURL + '/p/' + (note.alias || note.shortid))
|
||||||
|
break
|
||||||
|
case 'download':
|
||||||
|
exports.downloadMarkdown(req, res, note)
|
||||||
|
break
|
||||||
|
case 'info':
|
||||||
|
ActionController.getInfo(req, res, note)
|
||||||
|
break
|
||||||
|
case 'gist':
|
||||||
|
ActionController.createGist(req, res, note)
|
||||||
|
break
|
||||||
|
case 'revision':
|
||||||
|
ActionController.getRevision(req, res, note)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
return res.redirect(config.serverURL + '/' + noteId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function downloadMarkdown (req: Request, res: Response, note: any) {
|
||||||
|
const body = note.content
|
||||||
|
let filename = Note.decodeTitle(note.title)
|
||||||
|
filename = encodeURIComponent(filename)
|
||||||
|
res.set({
|
||||||
|
'Access-Control-Allow-Origin': '*', // allow CORS as API
|
||||||
|
'Access-Control-Allow-Headers': 'Range',
|
||||||
|
'Access-Control-Expose-Headers': 'Cache-Control, Content-Encoding, Content-Range',
|
||||||
|
'Content-Type': 'text/markdown; charset=UTF-8',
|
||||||
|
'Cache-Control': 'private',
|
||||||
|
'Content-disposition': 'attachment; filename=' + filename + '.md',
|
||||||
|
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
|
||||||
|
})
|
||||||
|
res.send(body)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { markdownParser } from '../utils'
|
|
||||||
|
|
||||||
import { SlideController } from './slide'
|
|
||||||
import { NoteController } from './controller'
|
|
||||||
import { Router } from 'express'
|
import { Router } from 'express'
|
||||||
|
import { markdownParser } from '../utils'
|
||||||
|
import * as NoteController from './controller'
|
||||||
|
|
||||||
|
import * as SlideController from './slide'
|
||||||
|
|
||||||
const NoteRouter = Router()
|
const NoteRouter = Router()
|
||||||
// get new note
|
// get new note
|
||||||
|
|
|
@ -1,52 +1,48 @@
|
||||||
import { NextFunction, Response } from "express";
|
import { NextFunction, Response } from 'express'
|
||||||
import { NoteUtils } from "./util";
|
import { config } from '../../config'
|
||||||
import { errors } from '../../errors'
|
import { errors } from '../../errors'
|
||||||
import { logger } from '../../logger'
|
import { logger } from '../../logger'
|
||||||
import { config } from '../../config'
|
import { Note, User } from '../../models'
|
||||||
import { User } from "../../models/user";
|
import * as NoteUtils from './util'
|
||||||
import { Note } from "../../models/note";
|
|
||||||
|
|
||||||
|
export function publishSlideActions (req: any, res: Response, next: NextFunction) {
|
||||||
export module SlideController {
|
NoteUtils.findNoteOrCreate(req, res, function (note) {
|
||||||
export function publishSlideActions(req: any, res: Response, next: NextFunction) {
|
const action = req.params.action
|
||||||
NoteUtils.findNoteOrCreate(req, res, function (note) {
|
if (action === 'edit') {
|
||||||
const action = req.params.action
|
res.redirect(config.serverURL + '/' + (note.alias ? note.alias : Note.encodeNoteId(note.id)) + '?both')
|
||||||
if (action === 'edit') {
|
} else {
|
||||||
res.redirect(config.serverURL + '/' + (note.alias ? note.alias : Note.encodeNoteId(note.id)) + '?both')
|
res.redirect(config.serverURL + '/p/' + note.shortid)
|
||||||
} else { res.redirect(config.serverURL + '/p/' + note.shortid) }
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function showPublishSlide (req: any, res: Response, next: NextFunction) {
|
||||||
|
const include = [{
|
||||||
export function showPublishSlide(req: any, res: Response, next: NextFunction) {
|
model: User,
|
||||||
const include = [{
|
as: 'owner'
|
||||||
model: User,
|
}, {
|
||||||
as: 'owner'
|
model: User,
|
||||||
}, {
|
as: 'lastchangeuser'
|
||||||
model: User,
|
}]
|
||||||
as: 'lastchangeuser'
|
NoteUtils.findNoteOrCreate(req, res, function (note) {
|
||||||
}]
|
// force to use short id
|
||||||
NoteUtils.findNoteOrCreate(req, res, function (note) {
|
const shortid = req.params.shortid
|
||||||
// force to use short id
|
if ((note.alias && shortid !== note.alias) || (!note.alias && shortid !== note.shortid)) {
|
||||||
const shortid = req.params.shortid
|
return res.redirect(config.serverURL + '/p/' + (note.alias || note.shortid))
|
||||||
if ((note.alias && shortid !== note.alias) || (!note.alias && shortid !== note.shortid)) {
|
}
|
||||||
return res.redirect(config.serverURL + '/p/' + (note.alias || note.shortid))
|
note.increment('viewcount').then(function (note) {
|
||||||
}
|
if (!note) {
|
||||||
note.increment('viewcount').then(function (note) {
|
return errors.errorNotFound(res)
|
||||||
if (!note) {
|
}
|
||||||
return errors.errorNotFound(res)
|
NoteUtils.getPublishData(req, res, note, (data) => {
|
||||||
}
|
res.set({
|
||||||
NoteUtils.getPublishData(req, res, note, (data) => {
|
'Cache-Control': 'private' // only cache by client
|
||||||
res.set({
|
})
|
||||||
'Cache-Control': 'private' // only cache by client
|
return res.render('slide.ejs', data)
|
||||||
})
|
})
|
||||||
return res.render('slide.ejs', data)
|
}).catch(function (err) {
|
||||||
})
|
logger.error(err)
|
||||||
}).catch(function (err) {
|
return errors.errorInternalError(res)
|
||||||
logger.error(err)
|
})
|
||||||
return errors.errorInternalError(res)
|
}, include)
|
||||||
})
|
|
||||||
}, include)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,113 +1,111 @@
|
||||||
import { Includeable } from 'sequelize'
|
|
||||||
import { Response } from 'express'
|
import { Response } from 'express'
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import { Includeable } from 'sequelize'
|
||||||
import { errors } from '../../errors'
|
|
||||||
import { config } from '../../config'
|
import { config } from '../../config'
|
||||||
|
import { errors } from '../../errors'
|
||||||
import { logger } from '../../logger'
|
import { logger } from '../../logger'
|
||||||
import { Note , User } from '../../models'
|
import { Note, User } from '../../models'
|
||||||
|
|
||||||
export module NoteUtils {
|
export function newNote (req: any, res: Response, body: string | null) {
|
||||||
export function findNoteOrCreate(req, res, callback: (note: any) => void, include?: Includeable[]) {
|
let owner = null
|
||||||
const id = req.params.noteId || req.params.shortid
|
const noteId = req.params.noteId ? req.params.noteId : null
|
||||||
Note.parseNoteId(id, function (err, _id) {
|
if (req.isAuthenticated()) {
|
||||||
if (err) {
|
owner = req.user.id
|
||||||
logger.error(err)
|
} else if (!config.allowAnonymous) {
|
||||||
return errors.errorInternalError(res)
|
return errors.errorForbidden(res)
|
||||||
|
}
|
||||||
|
if (config.allowFreeURL && noteId && !config.forbiddenNoteIDs.includes(noteId)) {
|
||||||
|
req.alias = noteId
|
||||||
|
} else if (noteId) {
|
||||||
|
return req.method === 'POST' ? errors.errorForbidden(res) : errors.errorNotFound(res)
|
||||||
|
}
|
||||||
|
Note.create({
|
||||||
|
ownerId: owner,
|
||||||
|
alias: req.alias ? req.alias : null,
|
||||||
|
content: body
|
||||||
|
}).then(function (note) {
|
||||||
|
return res.redirect(config.serverURL + '/' + (note.alias ? note.alias : Note.encodeNoteId(note.id)))
|
||||||
|
}).catch(function (err) {
|
||||||
|
logger.error(err)
|
||||||
|
return errors.errorInternalError(res)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkViewPermission (req: any, note: any) {
|
||||||
|
if (note.permission === 'private') {
|
||||||
|
return req.isAuthenticated() && note.ownerId === req.user.id
|
||||||
|
} else if (note.permission === 'limited' || note.permission === 'protected') {
|
||||||
|
return req.isAuthenticated()
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findNoteOrCreate (req, res, callback: (note: any) => void, include?: Includeable[]) {
|
||||||
|
const id = req.params.noteId || req.params.shortid
|
||||||
|
Note.parseNoteId(id, function (err, _id) {
|
||||||
|
if (err) {
|
||||||
|
logger.error(err)
|
||||||
|
return errors.errorInternalError(res)
|
||||||
|
}
|
||||||
|
Note.findOne({
|
||||||
|
where: {
|
||||||
|
id: _id
|
||||||
}
|
}
|
||||||
Note.findOne({
|
|
||||||
where: {
|
|
||||||
id: _id
|
|
||||||
}
|
|
||||||
}).then(function (note) {
|
|
||||||
if (!note) {
|
|
||||||
return newNote(req, res, "")
|
|
||||||
}
|
|
||||||
if (!checkViewPermission(req, note)) {
|
|
||||||
return errors.errorForbidden(res)
|
|
||||||
} else {
|
|
||||||
return callback(note)
|
|
||||||
}
|
|
||||||
}).catch(function (err) {
|
|
||||||
logger.error(err)
|
|
||||||
return errors.errorInternalError(res)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function checkViewPermission (req: any, note: any) {
|
|
||||||
if (note.permission === 'private') {
|
|
||||||
return req.isAuthenticated() && note.ownerId === req.user.id
|
|
||||||
} else if (note.permission === 'limited' || note.permission === 'protected') {
|
|
||||||
return req.isAuthenticated()
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function newNote (req: any, res: Response, body: string | null) {
|
|
||||||
let owner = null
|
|
||||||
const noteId = req.params.noteId ? req.params.noteId : null
|
|
||||||
if (req.isAuthenticated()) {
|
|
||||||
owner = req.user.id
|
|
||||||
} else if (!config.allowAnonymous) {
|
|
||||||
return errors.errorForbidden(res)
|
|
||||||
}
|
|
||||||
if (config.allowFreeURL && noteId && !config.forbiddenNoteIDs.includes(noteId)) {
|
|
||||||
req.alias = noteId
|
|
||||||
} else if (noteId) {
|
|
||||||
return req.method === 'POST' ? errors.errorForbidden(res) : errors.errorNotFound(res)
|
|
||||||
}
|
|
||||||
Note.create({
|
|
||||||
ownerId: owner,
|
|
||||||
alias: req.alias ? req.alias : null,
|
|
||||||
content: body
|
|
||||||
}).then(function (note) {
|
}).then(function (note) {
|
||||||
return res.redirect(config.serverURL + '/' + (note.alias ? note.alias : Note.encodeNoteId(note.id)))
|
if (!note) {
|
||||||
|
return newNote(req, res, '')
|
||||||
|
}
|
||||||
|
if (!checkViewPermission(req, note)) {
|
||||||
|
return errors.errorForbidden(res)
|
||||||
|
} else {
|
||||||
|
return callback(note)
|
||||||
|
}
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
return errors.errorInternalError(res)
|
return errors.errorInternalError(res)
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
|
}
|
||||||
export function getPublishData (req: any, res: Response, note: any, callback: (data: any) => void) {
|
|
||||||
const body = note.content
|
function isRevealTheme (theme: string) {
|
||||||
const extracted = Note.extractMeta(body)
|
if (fs.existsSync(path.join(__dirname, '..', '..', '..', '..', 'public', 'build', 'reveal.js', 'css', 'theme', theme + '.css'))) {
|
||||||
const markdown = extracted.markdown
|
return theme
|
||||||
const meta = Note.parseMeta(extracted.meta)
|
}
|
||||||
const createtime = note.createdAt
|
return undefined
|
||||||
const updatetime = note.lastchangeAt
|
}
|
||||||
let title = Note.decodeTitle(note.title)
|
|
||||||
title = Note.generateWebTitle(meta.title || title)
|
export function getPublishData (req: any, res: Response, note: any, callback: (data: any) => void) {
|
||||||
const ogdata = Note.parseOpengraph(meta, title)
|
const body = note.content
|
||||||
const data = {
|
const extracted = Note.extractMeta(body)
|
||||||
title: title,
|
const markdown = extracted.markdown
|
||||||
description: meta.description || (markdown ? Note.generateDescription(markdown) : null),
|
const meta = Note.parseMeta(extracted.meta)
|
||||||
viewcount: note.viewcount,
|
const createtime = note.createdAt
|
||||||
createtime: createtime,
|
const updatetime = note.lastchangeAt
|
||||||
updatetime: updatetime,
|
let title = Note.decodeTitle(note.title)
|
||||||
body: markdown,
|
title = Note.generateWebTitle(meta.title || title)
|
||||||
theme: meta.slideOptions && isRevealTheme(meta.slideOptions.theme),
|
const ogdata = Note.parseOpengraph(meta, title)
|
||||||
meta: JSON.stringify(extracted.meta),
|
const data = {
|
||||||
owner: note.owner ? note.owner.id : null,
|
title: title,
|
||||||
ownerprofile: note.owner ? User.getProfile(note.owner) : null,
|
description: meta.description || (markdown ? Note.generateDescription(markdown) : null),
|
||||||
lastchangeuser: note.lastchangeuser ? note.lastchangeuser.id : null,
|
viewcount: note.viewcount,
|
||||||
lastchangeuserprofile: note.lastchangeuser ? User.getProfile(note.lastchangeuser) : null,
|
createtime: createtime,
|
||||||
robots: meta.robots || false, // default allow robots
|
updatetime: updatetime,
|
||||||
GA: meta.GA,
|
body: markdown,
|
||||||
disqus: meta.disqus,
|
theme: meta.slideOptions && isRevealTheme(meta.slideOptions.theme),
|
||||||
cspNonce: res.locals.nonce,
|
meta: JSON.stringify(extracted.meta),
|
||||||
dnt: req.headers.dnt,
|
owner: note.owner ? note.owner.id : null,
|
||||||
opengraph: ogdata
|
ownerprofile: note.owner ? User.getProfile(note.owner) : null,
|
||||||
}
|
lastchangeuser: note.lastchangeuser ? note.lastchangeuser.id : null,
|
||||||
callback(data)
|
lastchangeuserprofile: note.lastchangeuser ? User.getProfile(note.lastchangeuser) : null,
|
||||||
}
|
robots: meta.robots || false, // default allow robots
|
||||||
|
GA: meta.GA,
|
||||||
function isRevealTheme (theme: string) {
|
disqus: meta.disqus,
|
||||||
if (fs.existsSync(path.join(__dirname, '..', '..', '..', 'public', 'build', 'reveal.js', 'css', 'theme', theme + '.css'))) {
|
cspNonce: res.locals.nonce,
|
||||||
return theme
|
dnt: req.headers.dnt,
|
||||||
}
|
opengraph: ogdata
|
||||||
return undefined
|
}
|
||||||
}
|
callback(data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,47 +110,47 @@ process.on('message', function (data: Data) {
|
||||||
return logger.error('dmp worker error: not enough data')
|
return logger.error('dmp worker error: not enough data')
|
||||||
}
|
}
|
||||||
switch (data.msg) {
|
switch (data.msg) {
|
||||||
case 'create patch':
|
case 'create patch':
|
||||||
if (data.lastDoc === undefined || data.currDoc === undefined) {
|
if (data.lastDoc === undefined || data.currDoc === undefined) {
|
||||||
return logger.error('dmp worker error: not enough data on create patch')
|
return logger.error('dmp worker error: not enough data on create patch')
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const patch: string = createPatch(data.lastDoc, data.currDoc)
|
const patch: string = createPatch(data.lastDoc, data.currDoc)
|
||||||
processSend({
|
processSend({
|
||||||
msg: 'check',
|
msg: 'check',
|
||||||
result: patch,
|
result: patch,
|
||||||
cacheKey: data.cacheKey
|
cacheKey: data.cacheKey
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('create patch: dmp worker error', err)
|
logger.error('create patch: dmp worker error', err)
|
||||||
processSend({
|
processSend({
|
||||||
msg: 'error',
|
msg: 'error',
|
||||||
error: err,
|
error: err,
|
||||||
cacheKey: data.cacheKey
|
cacheKey: data.cacheKey
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'get revision':
|
case 'get revision':
|
||||||
if (data.revisions === undefined || data.count === undefined) {
|
if (data.revisions === undefined || data.count === undefined) {
|
||||||
return logger.error('dmp worker error: not enough data on get revision')
|
return logger.error('dmp worker error: not enough data on get revision')
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||||
const result: { content: string; patch: patch_obj[]; authorship: string } = getRevision(data.revisions, data.count)
|
const result: { content: string; patch: patch_obj[]; authorship: string } = getRevision(data.revisions, data.count)
|
||||||
processSend({
|
processSend({
|
||||||
msg: 'check',
|
msg: 'check',
|
||||||
result: result,
|
result: result,
|
||||||
cacheKey: data.cacheKey
|
cacheKey: data.cacheKey
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('get revision: dmp worker error', err)
|
logger.error('get revision: dmp worker error', err)
|
||||||
processSend({
|
processSend({
|
||||||
msg: 'error',
|
msg: 'error',
|
||||||
error: err,
|
error: err,
|
||||||
cacheKey: data.cacheKey
|
cacheKey: data.cacheKey
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
/* eslint-env node, mocha */
|
/* eslint-env node, mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const assert = require('assert')
|
import assert from 'assert'
|
||||||
const crypto = require('crypto')
|
import crypto from 'crypto'
|
||||||
const fs = require('fs')
|
import fs from 'fs'
|
||||||
const path = require('path')
|
import path from 'path'
|
||||||
const mock = require('mock-require')
|
import * as configModule from '../lib/config'
|
||||||
|
import { ImportMock } from 'ts-mock-imports'
|
||||||
|
|
||||||
describe('Content security policies', function () {
|
describe('Content security policies', function () {
|
||||||
let defaultConfig, csp
|
let defaultConfig, csp
|
||||||
|
@ -31,22 +32,11 @@ describe('Content security policies', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
mock.stop('../lib/config')
|
|
||||||
csp = mock.reRequire('../lib/csp')
|
|
||||||
})
|
|
||||||
|
|
||||||
after(function () {
|
|
||||||
mock.stopAll()
|
|
||||||
csp = mock.reRequire('../lib/csp')
|
|
||||||
})
|
|
||||||
|
|
||||||
// beginnging Tests
|
// beginnging Tests
|
||||||
it('Disable CDN', function () {
|
it('Disable CDN', function () {
|
||||||
let testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.useCDN = false
|
testconfig.useCDN = false
|
||||||
mock('../lib/config', testconfig)
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
|
||||||
|
|
||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://cdnjs.cloudflare.com'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://cdnjs.cloudflare.com'))
|
||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://cdn.mathjax.org'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://cdn.mathjax.org'))
|
||||||
|
@ -57,19 +47,17 @@ describe('Content security policies', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Disable Google Analytics', function () {
|
it('Disable Google Analytics', function () {
|
||||||
let testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.csp.addGoogleAnalytics = false
|
testconfig.csp.addGoogleAnalytics = false
|
||||||
mock('../lib/config', testconfig)
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
|
||||||
|
|
||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://www.google-analytics.com'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://www.google-analytics.com'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Disable Disqus', function () {
|
it('Disable Disqus', function () {
|
||||||
let testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.csp.addDisqus = false
|
testconfig.csp.addDisqus = false
|
||||||
mock('../lib/config', testconfig)
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
|
||||||
|
|
||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://disqus.com'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://disqus.com'))
|
||||||
assert(!csp.computeDirectives().scriptSrc.includes('https://*.disqus.com'))
|
assert(!csp.computeDirectives().scriptSrc.includes('https://*.disqus.com'))
|
||||||
|
@ -79,18 +67,16 @@ describe('Content security policies', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Set ReportURI', function () {
|
it('Set ReportURI', function () {
|
||||||
let testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
testconfig.csp.reportURI = 'https://example.com/reportURI'
|
testconfig.csp.reportURI = 'https://example.com/reportURI'
|
||||||
mock('../lib/config', testconfig)
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
|
||||||
|
|
||||||
assert.strictEqual(csp.computeDirectives().reportUri, 'https://example.com/reportURI')
|
assert.strictEqual(csp.computeDirectives().reportUri, 'https://example.com/reportURI')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Set own directives', function () {
|
it('Set own directives', function () {
|
||||||
let testconfig = defaultConfig
|
const testconfig = defaultConfig
|
||||||
mock('../lib/config', defaultConfig)
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
|
||||||
const unextendedCSP = csp.computeDirectives()
|
const unextendedCSP = csp.computeDirectives()
|
||||||
testconfig.csp.directives = {
|
testconfig.csp.directives = {
|
||||||
defaultSrc: ['https://default.example.com'],
|
defaultSrc: ['https://default.example.com'],
|
||||||
|
@ -103,8 +89,7 @@ describe('Content security policies', function () {
|
||||||
childSrc: ['https://child.example.com'],
|
childSrc: ['https://child.example.com'],
|
||||||
connectSrc: ['https://connect.example.com']
|
connectSrc: ['https://connect.example.com']
|
||||||
}
|
}
|
||||||
mock('../lib/config', testconfig)
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
csp = mock.reRequire('../lib/csp')
|
|
||||||
|
|
||||||
const variations = ['default', 'script', 'img', 'style', 'font', 'object', 'media', 'child', 'connect']
|
const variations = ['default', 'script', 'img', 'style', 'font', 'object', 'media', 'child', 'connect']
|
||||||
|
|
||||||
|
@ -118,7 +103,7 @@ describe('Content security policies', function () {
|
||||||
*/
|
*/
|
||||||
it('Unchanged hash for reveal.js speaker notes plugin', function () {
|
it('Unchanged hash for reveal.js speaker notes plugin', function () {
|
||||||
const hash = crypto.createHash('sha1')
|
const hash = crypto.createHash('sha1')
|
||||||
hash.update(fs.readFileSync(path.resolve(__dirname, '../node_modules/reveal.js/plugin/notes/notes.html'), 'utf8'), 'utf8')
|
hash.update(fs.readFileSync(path.join(process.cwd(), '/node_modules/reveal.js/plugin/notes/notes.html'), 'utf8'), 'utf8')
|
||||||
assert.strictEqual(hash.digest('hex'), 'd5d872ae49b5db27f638b152e6e528837204d380')
|
assert.strictEqual(hash.digest('hex'), 'd5d872ae49b5db27f638b152e6e528837204d380')
|
||||||
})
|
})
|
||||||
})
|
})
|
|
@ -2,20 +2,21 @@
|
||||||
|
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const assert = require('assert')
|
import { ImportMock } from 'ts-mock-imports'
|
||||||
const mock = require('mock-require')
|
import * as configModule from '../lib/config'
|
||||||
|
|
||||||
|
import assert from 'assert'
|
||||||
|
import * as avatars from '../lib/letter-avatars'
|
||||||
|
|
||||||
describe('generateAvatarURL() gravatar enabled', function () {
|
describe('generateAvatarURL() gravatar enabled', function () {
|
||||||
let avatars
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
// Reset config to make sure we don't influence other tests
|
// Reset config to make sure we don't influence other tests
|
||||||
let testconfig = {
|
const testconfig = {
|
||||||
allowGravatar: true,
|
allowGravatar: true,
|
||||||
serverURL: 'http://localhost:3000',
|
serverURL: 'http://localhost:3000',
|
||||||
port: 3000
|
port: 3000
|
||||||
}
|
}
|
||||||
mock('../lib/config', testconfig)
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
avatars = mock.reRequire('../lib/letter-avatars')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return correct urls', function () {
|
it('should return correct urls', function () {
|
||||||
|
@ -29,16 +30,14 @@ describe('generateAvatarURL() gravatar enabled', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('generateAvatarURL() gravatar disabled', function () {
|
describe('generateAvatarURL() gravatar disabled', function () {
|
||||||
let avatars
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
// Reset config to make sure we don't influence other tests
|
// Reset config to make sure we don't influence other tests
|
||||||
let testconfig = {
|
const testconfig = {
|
||||||
allowGravatar: false,
|
allowGravatar: false,
|
||||||
serverURL: 'http://localhost:3000',
|
serverURL: 'http://localhost:3000',
|
||||||
port: 3000
|
port: 3000
|
||||||
}
|
}
|
||||||
mock('../lib/config', testconfig)
|
ImportMock.mockOther(configModule, 'config', testconfig)
|
||||||
avatars = mock.reRequire('../lib/letter-avatars')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return correct urls', function () {
|
it('should return correct urls', function () {
|
|
@ -1,15 +1,11 @@
|
||||||
/* eslint-env node, mocha */
|
/* eslint-env node, mocha */
|
||||||
|
|
||||||
'use strict'
|
import { User, sequelize } from '../lib/models'
|
||||||
|
import assert = require('assert')
|
||||||
const assert = require('assert')
|
|
||||||
|
|
||||||
const models = require('../lib/models')
|
|
||||||
const User = models.User
|
|
||||||
|
|
||||||
describe('User Sequelize model', function () {
|
describe('User Sequelize model', function () {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
return models.sequelize.sync({ force: true })
|
return sequelize.sync({ force: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores a password hash on creation and verifies that password', function () {
|
it('stores a password hash on creation and verifies that password', function () {
|
Loading…
Add table
Add a link
Reference in a new issue