mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-07 06:25:21 +02:00
jsops: migrate to ESM from CJM (#228)
* jsops: migrate to ESM from CJM * rm unused code * fix ci
This commit is contained in:
parent
f05eb15b72
commit
505daafc50
38 changed files with 509 additions and 309 deletions
|
@ -3,7 +3,7 @@ import config from 'config';
|
|||
import { expect } from 'chai';
|
||||
import Datastore from 'nedb';
|
||||
|
||||
import { Database } from '../backend/utils/database';
|
||||
import { Database } from '../backend/utils/database/index.js';
|
||||
|
||||
interface Document {
|
||||
data?: any;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import chaiHTTP from 'chai-http';
|
||||
import chai, { expect } from 'chai';
|
||||
|
||||
import server from '../bin/server';
|
||||
import server from '../bin/server.js';
|
||||
|
||||
const app = server.app;
|
||||
|
||||
|
@ -16,4 +16,4 @@ describe('Express app', () => {
|
|||
|
||||
expect(result).to.have.status(200);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,12 +2,20 @@ import { expect } from 'chai';
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import config from 'config';
|
||||
import Alias from '../../backend/models/alias';
|
||||
import { binaryMD5 } from '../../backend/utils/crypto';
|
||||
import database from '../../backend/utils/database';
|
||||
import Alias from '../../backend/models/alias.js';
|
||||
import { binaryMD5 } from '../../backend/utils/crypto.js';
|
||||
import database from '../../backend/utils/database/index.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const aliases = database['aliases'];
|
||||
|
||||
/**
|
||||
* The __dirname CommonJS variables are not available in ES modules.
|
||||
* https://nodejs.org/api/esm.html#no-__filename-or-__dirname
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
describe('Alias model', () => {
|
||||
after(() => {
|
||||
const pathToDB = path.resolve(__dirname, '../../../', config.get('database'), './aliases.db');
|
||||
|
|
|
@ -2,8 +2,16 @@ import { expect } from 'chai';
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import config from 'config';
|
||||
import File from '../../backend/models/file';
|
||||
import database from '../../backend/utils/database';
|
||||
import File from '../../backend/models/file.js';
|
||||
import database from '../../backend/utils/database/index.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
/**
|
||||
* The __dirname CommonJS variables are not available in ES modules.
|
||||
* https://nodejs.org/api/esm.html#no-__filename-or-__dirname
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const files = database['files'];
|
||||
|
||||
|
@ -159,9 +167,9 @@ describe('File model', () => {
|
|||
|
||||
if (savedFile._id !== undefined){
|
||||
const foundFile = await File.get(savedFile._id);
|
||||
|
||||
|
||||
const { data } = foundFile;
|
||||
|
||||
|
||||
expect(data._id).to.equal(savedFile._id);
|
||||
expect(data.name).to.equal(savedFile.name);
|
||||
expect(data.filename).to.equal(savedFile.filename);
|
||||
|
@ -188,9 +196,9 @@ describe('File model', () => {
|
|||
|
||||
if (savedFile.filename !== undefined){
|
||||
const foundFile = await File.getByFilename(savedFile.filename);
|
||||
|
||||
|
||||
const { data } = foundFile;
|
||||
|
||||
|
||||
expect(data._id).to.equal(savedFile._id);
|
||||
expect(data.name).to.equal(savedFile.name);
|
||||
expect(data.filename).to.equal(savedFile.filename);
|
||||
|
|
|
@ -2,9 +2,17 @@ import { expect } from 'chai';
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import config from 'config';
|
||||
import Page from '../../backend/models/page';
|
||||
import translateString from '../../backend/utils/translation';
|
||||
import database from '../../backend/utils/database';
|
||||
import Page from '../../backend/models/page.js';
|
||||
import translateString from '../../backend/utils/translation.js';
|
||||
import database from '../../backend/utils/database/index.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
/**
|
||||
* The __dirname CommonJS variables are not available in ES modules.
|
||||
* https://nodejs.org/api/esm.html#no-__filename-or-__dirname
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const pages = database['pages'];
|
||||
|
||||
|
|
|
@ -2,8 +2,16 @@ import { expect } from 'chai';
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import config from 'config';
|
||||
import PageOrder from '../../backend/models/pageOrder';
|
||||
import database from '../../backend/utils/database';
|
||||
import PageOrder from '../../backend/models/pageOrder.js';
|
||||
import database from '../../backend/utils/database/index.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
/**
|
||||
* The __dirname CommonJS variables are not available in ES modules.
|
||||
* https://nodejs.org/api/esm.html#no-__filename-or-__dirname
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const pagesOrder = database['pagesOrder'];
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import path from 'path';
|
|||
import config from 'config';
|
||||
import sinon = require('sinon');
|
||||
|
||||
import rcParser from '../backend/utils/rcparser';
|
||||
import rcParser from '../backend/utils/rcparser.js';
|
||||
|
||||
const rcPath = path.resolve(process.cwd(), config.get('rcFile'));
|
||||
|
||||
|
|
|
@ -3,7 +3,15 @@ import path from 'path';
|
|||
import config from 'config';
|
||||
import chai from 'chai';
|
||||
import chaiHTTP from 'chai-http';
|
||||
import server from '../../bin/server';
|
||||
import server from '../../bin/server.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
/**
|
||||
* The __dirname CommonJS variables are not available in ES modules.
|
||||
* https://nodejs.org/api/esm.html#no-__filename-or-__dirname
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const {expect} = chai;
|
||||
const app = server.app;
|
||||
|
|
|
@ -3,11 +3,20 @@ import path from 'path';
|
|||
import config from 'config';
|
||||
import chai from 'chai';
|
||||
import chaiHTTP from 'chai-http';
|
||||
import server from '../../bin/server';
|
||||
import model from '../../backend/models/page';
|
||||
import Page from '../../backend/models/page';
|
||||
import PageOrder from '../../backend/models/pageOrder';
|
||||
import translateString from '../../backend/utils/translation';
|
||||
import server from '../../bin/server.js';
|
||||
import model from '../../backend/models/page.js';
|
||||
import Page from '../../backend/models/page.js';
|
||||
import PageOrder from '../../backend/models/pageOrder.js';
|
||||
import translateString from '../../backend/utils/translation.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
/**
|
||||
* The __dirname CommonJS variables are not available in ES modules.
|
||||
* https://nodejs.org/api/esm.html#no-__filename-or-__dirname
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
|
||||
const {expect} = chai;
|
||||
const app = server.app;
|
||||
|
@ -516,7 +525,7 @@ describe('Pages REST: ', () => {
|
|||
|
||||
page6 = await Page.get(pages[6]);
|
||||
expect(page6.data._id).to.be.undefined;
|
||||
|
||||
|
||||
page7 = await Page.get(pages[7]);
|
||||
expect(page7.data._id).to.be.undefined;
|
||||
|
||||
|
|
|
@ -5,8 +5,17 @@ import chai from 'chai';
|
|||
import chaiHTTP from 'chai-http';
|
||||
import rimraf from 'rimraf';
|
||||
import config from 'config';
|
||||
import server from '../../bin/server';
|
||||
import model from '../../backend/models/file';
|
||||
import server from '../../bin/server.js';
|
||||
import model from '../../backend/models/file.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
/**
|
||||
* The __dirname CommonJS variables are not available in ES modules.
|
||||
* https://nodejs.org/api/esm.html#no-__filename-or-__dirname
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
|
||||
const {expect} = chai;
|
||||
const app = server.app;
|
||||
|
@ -119,7 +128,7 @@ describe('Transport routes: ', () => {
|
|||
if (file.path !== undefined){
|
||||
const getRes = await agent
|
||||
.get(file.path);
|
||||
|
||||
|
||||
expect(getRes).to.have.status(200);
|
||||
expect(getRes).to.have.header('content-type', new RegExp(`^${file.mimetype}`));
|
||||
}
|
||||
|
@ -170,7 +179,7 @@ describe('Transport routes: ', () => {
|
|||
if (file.path !== undefined){
|
||||
const getRes = await agent
|
||||
.get(file.path);
|
||||
|
||||
|
||||
expect(getRes).to.have.status(200);
|
||||
expect(getRes).to.have.header('content-type', file.mimetype);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue