fix conflicts
This commit is contained in:
@@ -29,7 +29,7 @@ class APIError extends ExtendableError {
|
||||
* @param {object} data - response data to be returned.
|
||||
* @param {boolean} isPublic - Whether the message should be visible to user or not.
|
||||
*/
|
||||
constructor(message, status = httpStatus.INTERNAL_SERVER_ERROR, data, isPublic = false) {
|
||||
constructor(message: string, status: number = httpStatus.INTERNAL_SERVER_ERROR, data: any, isPublic: boolean = false) {
|
||||
super(message, status, data, isPublic);
|
||||
}
|
||||
}
|
||||
|
||||
11
src/index.ts
11
src/index.ts
@@ -1,5 +1,7 @@
|
||||
import { PayloadConfig, PayloadCollection, PayloadInitOptions } from './types';
|
||||
import express from 'express';
|
||||
import crypto from 'crypto';
|
||||
import { Router } from 'express';
|
||||
import Logger from './utilities/logger';
|
||||
import bindOperations from './init/bindOperations';
|
||||
import bindRequestHandlers from './init/bindRequestHandlers';
|
||||
@@ -30,11 +32,14 @@ require('isomorphic-fetch');
|
||||
const logger = Logger();
|
||||
|
||||
class Payload {
|
||||
config: PayloadConfig;
|
||||
collections: PayloadCollection[] = [];
|
||||
logger: any;
|
||||
router: Router;
|
||||
|
||||
init(options) {
|
||||
init(options: PayloadInitOptions) {
|
||||
this.logger = logger;
|
||||
this.logger.info('Starting Payload...');
|
||||
logger.info('Starting Payload...');
|
||||
|
||||
if (!options.secret) {
|
||||
throw new Error('Error: missing secret key. A secret key is needed to secure Payload.');
|
||||
@@ -58,7 +63,7 @@ class Payload {
|
||||
|
||||
if (typeof this.config.paths === 'undefined') this.config.paths = {};
|
||||
|
||||
this.collections = {};
|
||||
// this.collections = {};
|
||||
|
||||
bindOperations(this);
|
||||
bindRequestHandlers(this);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { PayloadConfig } from '../types';
|
||||
import defaultUser from '../auth/default';
|
||||
import sanitizeCollection from '../collections/sanitize';
|
||||
import { InvalidConfiguration } from '../errors';
|
||||
@@ -5,7 +6,7 @@ import sanitizeGlobals from '../globals/sanitize';
|
||||
import validateSchema from '../schema/validateSchema';
|
||||
import checkDuplicateCollections from './checkDuplicateCollections';
|
||||
|
||||
const sanitizeConfig = (config) => {
|
||||
const sanitizeConfig = (config: PayloadConfig) => {
|
||||
const sanitizedConfig = validateSchema({ ...config });
|
||||
|
||||
// TODO: remove default values from sanitize in favor of assigning in the schema within validateSchema and use https://www.npmjs.com/package/ajv#coercing-data-types where needed
|
||||
|
||||
Reference in New Issue
Block a user