How to use nocache - 5 common examples

To help you get started, we’ve selected a few nocache 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 Netflix-Skunkworks / stethoscope-app / src / server.js View on Github external
export default async function startServer (env, log, language = 'en-US', appActions) {
  log.info('starting express server')
  const checks = await precompile()
  const find = filePath => path.join(__dirname, filePath)
  const settingsHandle = readFileSync(find('./practices/config.yaml'), 'utf8')
  const defaultConfig = yaml.safeLoad(settingsHandle)

  app.use(helmet())
  app.use(noCache())
  app.use(bodyParser.urlencoded({ extended: true }))
  app.use(bodyParser.json())

  const schema = makeExecutableSchema({
    resolvers: Resolvers,
    typeDefs: Schema
  })

  const { allowHosts = [], hostLabels = [] } = defaultConfig

  // wide open in dev, limited to hosts specified in './practices/config.yaml' in production
  const corsOptions = {
    origin (origin, callback) {
      if (IS_DEV) { return callback(null, true) }
      if (allowHosts.includes(origin)) { return callback(null, true) }
      if (hostLabels.length) {
github Netflix / pollyjs / packages / @pollyjs / node-server / src / express / register-api.js View on Github external
export default function registerAPI(app, config) {
  config = { ...DefaultConfig, ...config };
  config.apiNamespace = prependSlash(config.apiNamespace);

  const router = express.Router();
  const api = new API({ recordingsDir: config.recordingsDir });

  router.use(nocache());

  router.get('/:recording', function(req, res) {
    const { recording } = req.params;
    const { status, body } = api.getRecording(recording);

    res.status(status);

    if (status === 200) {
      res.json(body);
    } else {
      res.end();
    }
  });

  router.post(
    '/:recording',
github twilio-labs / twilio-run / src / runtime / server.ts View on Github external
const app = express();
  app.use(userAgentMiddleware.express());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  app.get('/favicon.ico', (req, res) => {
    res.redirect(
      'https://www.twilio.com/marketing/bundles/marketing/img/favicons/favicon.ico'
    );
  });

  if (config.logs) {
    app.use(createLogger(config));
  }

  if (config.live) {
    app.use(nocache());
  }

  if (config.legacyMode) {
    process.env.TWILIO_FUNCTIONS_LEGACY_MODE = config.legacyMode
      ? 'true'
      : undefined;
    debug('Legacy mode enabled');
    app.use('/assets/*', (req, res, next) => {
      req.path = req.path.replace('/assets/', '/');
      next();
    });
  }

  const routes = await getFunctionsAndAssets(config.baseDir);
  const routeMap = setRoutes(routes);
github globocom / gcrypt / api / src / web / routes / index.js View on Github external
export default (() => {
  const app = express();

  app.disable('x-powered-by');
  app.use(nocache());
  app.use(morgan('short'));

  morgan.token('remote-user', request => request.jti || 'anonymous');

  app.use('/auth', authRouter);

  app.get('/health', (request, response) => {
    response.send('OK');
  });

  return app;
})();
github tonyfromundefined / next-starter / serverless / main.ts View on Github external
const BINARY_MIME_TYPES = [
  'application/javascript',
  'application/json',
  'application/octet-stream',
  'application/xml',
  'text/css',
  'text/html',
  'text/javascript',
  'text/plain',
  'text/text',
  'text/xml',
]

const app = asyncify(express())

app.use(nocache())
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(cookieParser())

app.use(api)

app.get('/', (index as any).render)
app.get('/_error', (error as any).render)

const server = awsServerlessExpress.createServer(app, undefined, BINARY_MIME_TYPES)

export const handler = (event: any, context: Context) => {
  return awsServerlessExpress.proxy(server, event, context)
}

nocache

Middleware to destroy caching

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis

Popular nocache functions