ESLint fixes for Notes

Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
David Mehren 2020-04-25 20:58:38 +02:00
parent acdd627027
commit 5cda02590b
No known key found for this signature in database
GPG key ID: 6017AF117F9756CB
5 changed files with 269 additions and 277 deletions

View file

@ -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'

View file

@ -1,12 +1,11 @@
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
@ -137,4 +136,3 @@ export module NoteController {
}) })
res.send(body) res.send(body)
} }
}

View file

@ -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

View file

@ -1,24 +1,21 @@
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 module SlideController {
export function publishSlideActions (req: any, res: Response, next: NextFunction) { export function publishSlideActions (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
if (action === 'edit') { if (action === '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')
} else { res.redirect(config.serverURL + '/p/' + note.shortid) } } else {
res.redirect(config.serverURL + '/p/' + note.shortid)
}
}) })
} }
export function showPublishSlide (req: any, res: Response, next: NextFunction) { export function showPublishSlide (req: any, res: Response, next: NextFunction) {
const include = [{ const include = [{
model: User, model: User,
@ -49,4 +46,3 @@ export module SlideController {
}) })
}, include) }, include)
} }
}

View file

@ -1,14 +1,13 @@
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 findNoteOrCreate (req, res, callback: (note: any) => void, include?: Includeable[]) { export function findNoteOrCreate (req, res, callback: (note: any) => void, include?: Includeable[]) {
const id = req.params.noteId || req.params.shortid const id = req.params.noteId || req.params.shortid
Note.parseNoteId(id, function (err, _id) { Note.parseNoteId(id, function (err, _id) {
@ -110,4 +109,3 @@ export module NoteUtils {
} }
return undefined return undefined
} }
}