This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { promises, createReadStream } from 'fs'; | |
import StreamArray from 'stream-json/streamers/StreamArray'; | |
export const jsonFromFile = async <T>(filepath: string): Promise<T> => { | |
return promises | |
.readFile(filepath, { | |
encoding: 'utf-8', | |
}) | |
.then((jsonString) => JSON.parse(jsonString)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pages/api/webhooks/datocms/revalidate-pages.function.ts | |
// custom page extensions in next.config.js: pageExtensions: ['page.tsx', 'function.ts', 'page.jsx', 'function.js'], | |
import type { NextApiRequest, NextApiResponse } from 'next'; | |
import { i18n } from 'next.config'; | |
import type { Payload } from './types'; | |
import { | |
getModelId, | |
getWebhookHeaders, | |
revalidateMultiplePaths, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pages/_document.tsx | |
import Document, { | |
provideComponents, | |
} from '@next-safe/middleware/dist/document'; | |
import { Html, Main } from 'next/document'; | |
import React from 'react'; | |
export default class MyDocument extends Document { | |
static async getInitialProps(ctx: any) { |