@naturalcycles/backend-lib 9.0.0 → 9.0.1

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.
@@ -1,6 +1,7 @@
1
1
  import { _memoFn, AppError } from '@naturalcycles/js-lib';
2
2
  import { fs2 } from '@naturalcycles/nodejs-lib';
3
3
  import ejs from 'ejs';
4
+ import { srcDir } from '../paths.cnst.js';
4
5
  export function createAdminMiddleware(adminService, cfgDefaults = {}) {
5
6
  return (reqPermissions, cfg) => requireAdminPermissions(adminService, reqPermissions, {
6
7
  ...cfgDefaults,
@@ -46,7 +47,7 @@ export function loginHtml(firebaseServiceCfg) {
46
47
  }
47
48
  const getLoginHtml = _memoFn((cfg) => {
48
49
  console.log(`reading login.html`);
49
- const tmpl = fs2.readText(`${__dirname}/login.html`);
50
+ const tmpl = fs2.readText(`${srcDir}/admin/login.html`);
50
51
  return ejs.render(tmpl, cfg);
51
52
  });
52
53
  export function getLoginHtmlRedirect(href) {
@@ -1,5 +1,8 @@
1
- import path from 'node:path';
2
- export const projectDir = path.join(__dirname, '/..');
1
+ import { dirname, join } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ const __filename = fileURLToPath(import.meta.url);
4
+ const __dirname = dirname(__filename);
5
+ export const projectDir = join(__dirname, '/..');
3
6
  export const resourcesDir = `${projectDir}/resources`;
4
7
  export const srcDir = `${projectDir}/src`;
5
8
  export const testDir = `${srcDir}/test`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
3
  "type": "module",
4
- "version": "9.0.0",
4
+ "version": "9.0.1",
5
5
  "scripts": {
6
6
  "prepare": "husky",
7
7
  "build": "dev-lib build",
@@ -1,6 +1,7 @@
1
1
  import { _memoFn, AppError } from '@naturalcycles/js-lib'
2
2
  import { fs2 } from '@naturalcycles/nodejs-lib'
3
3
  import ejs from 'ejs'
4
+ import { srcDir } from '../paths.cnst.js'
4
5
  import type { BackendRequestHandler } from '../server/server.model.js'
5
6
  import type { BaseAdminService } from './base.admin.service.js'
6
7
  import type { FirebaseSharedServiceCfg } from './firebase.shared.service.js'
@@ -101,7 +102,7 @@ export function loginHtml(firebaseServiceCfg: FirebaseSharedServiceCfg): Backend
101
102
 
102
103
  const getLoginHtml = _memoFn((cfg: LoginHtmlCfg) => {
103
104
  console.log(`reading login.html`)
104
- const tmpl = fs2.readText(`${__dirname}/login.html`)
105
+ const tmpl = fs2.readText(`${srcDir}/admin/login.html`)
105
106
  return ejs.render(tmpl, cfg)
106
107
  })
107
108
 
package/src/paths.cnst.ts CHANGED
@@ -1,6 +1,10 @@
1
- import path from 'node:path'
1
+ import { dirname, join } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
2
3
 
3
- export const projectDir = path.join(__dirname, '/..')
4
+ const __filename = fileURLToPath(import.meta.url)
5
+ const __dirname = dirname(__filename)
6
+
7
+ export const projectDir = join(__dirname, '/..')
4
8
  export const resourcesDir = `${projectDir}/resources`
5
9
  export const srcDir = `${projectDir}/src`
6
10
  export const testDir = `${srcDir}/test`