velocious 1.0.25 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "velocious": "bin/velocious.js"
4
4
  },
5
5
  "name": "velocious",
6
- "version": "1.0.25",
6
+ "version": "1.0.26",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "test": "jasmine",
@@ -13,9 +13,9 @@ export default class DbGenerateMigration extends BaseCommand {
13
13
  const date = new Date()
14
14
  const migrationNumber = strftime("%Y%m%d%H%M%S")
15
15
  const migrationFileName = `${migrationNumber}-${migrationName}.js`
16
- const __filename = fileURLToPath(`${import.meta.url}/../../..`)
16
+ const __filename = fileURLToPath(import.meta.url)
17
17
  const __dirname = dirname(__filename)
18
- const templateFilePath = `${__dirname}/templates/generate-migration.js`
18
+ const templateFilePath = `${__dirname}/../../../templates/generate-migration.js`
19
19
  const migrationContentBuffer = await fs.readFile(templateFilePath)
20
20
  const migrationContent = migrationContentBuffer.toString().replaceAll("__MIGRATION_NAME__", migrationNameCamelized)
21
21
  const migrationDir = `${process.cwd()}/src/database/migrations`
@@ -8,9 +8,10 @@ export default class VelociousConfiguration {
8
8
  return this.velociousConfiguration
9
9
  }
10
10
 
11
- constructor({database, debug, directory, initializeModels, locale, localeFallbacks, locales, ...restArgs}) {
11
+ constructor({cors, database, debug, directory, initializeModels, locale, localeFallbacks, locales, ...restArgs}) {
12
12
  restArgsError(restArgs)
13
13
 
14
+ this.cors = cors
14
15
  this.database = database
15
16
  this.debug = debug
16
17
  this._directory = directory
@@ -24,9 +24,14 @@ export default class VelociousHttpServerClientRequestRunner {
24
24
  if (!request) throw new Error("No request?")
25
25
 
26
26
  try {
27
- if (request.httpMethod() == "OPTIONS" && request.header("sec-fetch-mode") == "cors") {
27
+ if (request.header("sec-fetch-mode") == "cors") {
28
28
  await logger(this, () => ["Run CORS", {httpMethod: request.httpMethod(), secFetchMode: request.header("sec-fetch-mode")}])
29
29
  await configuration.cors({request, response})
30
+ }
31
+
32
+ if (request.httpMethod() == "OPTIONS" && request.header("sec-fetch-mode") == "cors") {
33
+ response.setStatus(200)
34
+ response.setBody("")
30
35
  } else {
31
36
  await logger(this, "Run request")
32
37
  const routesResolver = new RoutesResolver({configuration, request, response})