How to use the jsonapi-serializer.Error function in jsonapi-serializer

To help you get started, we’ve selected a few jsonapi-serializer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oberonamsterdam / jsonapi-mock / src / index.js View on Github external
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
import express from 'express';
import http from 'http';
import jsonapiSerializer from 'jsonapi-serializer';
import logger from 'morgan';
import { globalAccept, globalContentType, mainRoutes, port } from './constants/Globals';
import router from './routes/routes';
import './services/CheckEnvVars';
import { isValid, NotFoundhandler, onError } from './services/Helpers';

// const declaration
const app = express();
const JSONAPIError = jsonapiSerializer.Error;

// middleware
app.use(logger('dev'));
app.use(bodyParser.json({ type: globalContentType }));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());

app.use((req, res, next) => {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
    res.header('Content-Type', globalContentType);
    res.header('Accept', globalContentType);
    res.removeHeader('X-Powered-By');
    next();
});

jsonapi-serializer

A Node.js framework agnostic library for serializing your data to JSON API

MIT
Latest version published 10 months ago

Package Health Score

67 / 100
Full package analysis