Cors : so simple

const cors = require('cors');

app.use(cors({ origin: /http:\/\/(127(\.\d){3}|localhost)/})); 

app.options('*', cors());


On remarque la regExp :  http:\/\/(127(\.\d){3}|localhost)

Soit  http:\/\/(127(\.\d){3} cad http://127.nb.nb.nb 

ou localhost

__dirname

 

__dirname 

n'est pas reconnu lorsque l'on passe en version de module EJS. Voici deux solutions possibles.

🪛Redéfinir __dirname 
import { dirname } from "path";
import { fileURLToPath } from "url";

const __dirname = dirname(fileURLToPath(import.meta.url)); 
const data = await readFile(__dirname + path);


🪛Oublier __dirname 

import { URL } from "node:url";
const data = await readFile(new URL(path, import.meta.url));

DATE

const timestamp = new Date().getTime();
console.log(timestamp)

let DAY_FORMATTER = new Intl.DateTimeFormat(undefined, { weekday: "long",
month: "long" })
console.log(DAY_FORMATTER.format(timestamp))

DAY_FORMATTER = new Intl.DateTimeFormat(undefined, { dayPeriod: "short"
, weekday: "short", year: "numeric"
, month: "short", day: "numeric" })
console.log(DAY_FORMATTER.format(0))

Les valeurs possibles : 
{
  weekday: 'narrow' | 'short' | 'long',
  era: 'narrow' | 'short' | 'long',
  year: 'numeric' | '2-digit',
  month: 'numeric' | '2-digit' | 'narrow' | 'short' | 'long',
  day: 'numeric' | '2-digit',
  hour: 'numeric' | '2-digit',
  minute: 'numeric' | '2-digit',
  second: 'numeric' | '2-digit',
  timeZoneName: 'short' | 'long',

  // Time zone to express it in
  timeZone: 'Asia/Shanghai',
  // Force 12-hour or 24-hour
  hour12: true | false,
}

vite

npm create vite@latest

npm i

npm run dev