Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@okam/directus-node

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@okam/directus-node

This library was generated with [Nx](https://nx.dev).

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
101
increased by573.33%
Maintainers
0
Weekly downloads
 
Created
Source

directus-node

This library was generated with Nx.

Building

Run nx build directus-node to build the library.

Running unit tests

Run nx test directus-node to execute the unit tests via Jest.

Redirection

  1. Create a fetch-redirect.js file in your next.js folder and require fetchRedirects
/**
 * Usage
 * In apps/contest-nextjs directory
 * npx env-cmd -f ../../.env.local node fetch-redirect.js
 */
const { fetchRedirects, getDefaultConfig } = require('@okam/directus-node')

// getDefaultConfig() will return an object with
// graphqlEndpoint: use environment variable NEXT_PUBLIC_GRAPHQL_URL
// graphqlApiKey: use environment variable NEXT_API_TOKEN_ADMIN
// redirectsFilename
// rewritesFilename
// limit: 2000  (number of redirect or rewrite rules fetched by graphql)
fetchRedirects(getDefaultConfig())
  1. In project.json,
  2. In targets.build, add "dependsOn": ["fetch-redirect"],
  3. In targets:
    "fetch-redirect": {
      "executor": "nx:run-commands",
      "options": {
        "cwd": "{projectRoot}",
        "command": "node fetch-redirect"
      }
    },
  1. Don't forget to change the cwd path

  2. Create directory redirect

  3. Create file redirect/index.js

const redirects = require('./redirects.json')
const rewrites = require('./rewrites.json')

module.exports = {
  redirects: async () => redirects,
  rewrites: async () => rewrites,
}

  1. Define environments variables
NEXT_PUBLIC_GRAPHQL_URL=
NEXT_API_TOKEN_ADMIN=
  1. Generate redirect/redirects.json and redirect/rewrites.json using fetch-redirect (or build project with nx)
npx env-cmd -f ../../.env.local node fetch-redirect.js
  1. Update nextConfig in next.config.js with
const { rewrites, redirects } = require('./redirect/index')
const nextConfig = {
...
  async redirects() {
    const rest = await redirects()
    return [
       ...i18nReRouter({locale: false, permanent: true}, 'redirect'),
       ...rest,
    ]
    return rest
  },
  async rewrites() {
    const fallback = await rewrites()
    return {
      beforeFiles: [
        ...i18nReRouter({locale: false}, 'rewrite'),
      ],
      afterFiles: [
        ...i18nRewriter({...i18nConfigWithoutLocaleDetector, localeDetector: false}),
      ],
      fallback,
    }
  },
...
}

FAQs

Package last updated on 19 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc