Fix prettier errors

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-01-05 23:11:31 +01:00
parent c6cdba4844
commit f0835f5b62
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
4 changed files with 28 additions and 24 deletions

View file

@ -17,21 +17,24 @@ import * as getRawBody from 'raw-body';
* *
* Implementation inspired by https://stackoverflow.com/questions/52283713/how-do-i-pass-plain-text-as-my-request-body-using-nestjs * Implementation inspired by https://stackoverflow.com/questions/52283713/how-do-i-pass-plain-text-as-my-request-body-using-nestjs
*/ */
export const MarkdownBody = createParamDecorator(async (_, context: ExecutionContext) => { export const MarkdownBody = createParamDecorator(
// we have to check req.readable because of raw-body issue #57 async (_, context: ExecutionContext) => {
// https://github.com/stream-utils/raw-body/issues/57 // we have to check req.readable because of raw-body issue #57
const req = context.switchToHttp().getRequest<import('express').Request>(); // https://github.com/stream-utils/raw-body/issues/57
// Here the Content-Type of the http request is checked to be text/markdown const req = context.switchToHttp().getRequest<import('express').Request>();
// because we dealing with markdown. Technically by now there can be any content which can be encoded. // Here the Content-Type of the http request is checked to be text/markdown
// There could be features in the software which do not work properly if the text can't be parsed as markdown. // because we dealing with markdown. Technically by now there can be any content which can be encoded.
if (req.get('Content-Type') === 'text/markdown') { // There could be features in the software which do not work properly if the text can't be parsed as markdown.
if (req.readable) { if (req.get('Content-Type') === 'text/markdown') {
return (await getRawBody(req)).toString().trim(); if (req.readable) {
return (await getRawBody(req)).toString().trim();
} else {
throw new InternalServerErrorException('Failed to parse request body!');
}
} else { } else {
throw new InternalServerErrorException('Failed to parse request body!'); throw new BadRequestException(
'Body Content-Type has to be text/markdown!',
);
} }
} else { },
throw new BadRequestException('Body Content-Type has to be text/markdown!'); );
}
});

View file

@ -25,7 +25,7 @@ async function getServerVersionFromPackageJson() {
const packageInfo: { version: string } = JSON.parse(rawFileContent); const packageInfo: { version: string } = JSON.parse(rawFileContent);
const versionParts: number[] = packageInfo.version const versionParts: number[] = packageInfo.version
.split('.') .split('.')
.map((x) => parseInt(x, 10)); .map(x => parseInt(x, 10));
versionCache = { versionCache = {
major: versionParts[0], major: versionParts[0],
minor: versionParts[1], minor: versionParts[1],

View file

@ -5,11 +5,13 @@
*/ */
import { import {
Column, CreateDateColumn, Column,
CreateDateColumn,
Entity, Entity,
ManyToMany, ManyToMany,
ManyToOne, ManyToOne,
PrimaryGeneratedColumn, UpdateDateColumn, PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm/index'; } from 'typeorm/index';
import { User } from '../users/user.entity'; import { User } from '../users/user.entity';
import { Revision } from './revision.entity'; import { Revision } from './revision.entity';
@ -38,14 +40,14 @@ export class Authorship {
user: User; user: User;
@Column() @Column()
startPos: number startPos: number;
@Column() @Column()
endPos: number endPos: number;
@CreateDateColumn() @CreateDateColumn()
createdAt: Date createdAt: Date;
@UpdateDateColumn() @UpdateDateColumn()
updatedAt: Date updatedAt: Date;
} }

View file

@ -124,7 +124,6 @@ describe('Notes', () => {
expect(historyEntry.pinStatus).toEqual(true); expect(historyEntry.pinStatus).toEqual(true);
}); });
it.skip(`GET /me/notes/`, async () => { it.skip(`GET /me/notes/`, async () => {
// TODO use function from HistoryService to add an History Entry // TODO use function from HistoryService to add an History Entry
await notesService.createNote('This is a test note.', 'test7'); await notesService.createNote('This is a test note.', 'test7');