Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/routes_mounted.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import request from "supertest"
import api_routes from "../routes/api-routes.js"
import app from "../app.js"
import api_routes from "../src/services/api-routes.js"
import app from "../src/index.js"
import fs from "fs"

let app_stack = app.router.stack
Expand Down
2 changes: 1 addition & 1 deletion bin/rerum_v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Module dependencies.
*/

import app from '../app.js'
import app from '../src/index.js'
import debug from 'debug'
debug('rerum_server_nodejs:server')
import http from "http"
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const config = {
collectCoverageFrom: [
//"**/*.js",
"**/db-controller.js",
"**/routes/*.js"
"**/services/*.js"
],

// Indicates which provider should be used to instrument code for coverage
Expand Down
9 changes: 0 additions & 9 deletions routes/index.js

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* If that is what you need, get out of here and go see /auth/__mocks__
*/

import auth from "../../auth/index.js"
import auth from "../index.js"
import httpMocks from "node-mocks-http"

const goodToken = "TODO -- MAKE ME PROGRAMMATICALLY"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions controllers/bulk.js → src/controllers/bulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @author Claude Sonnet 4, cubap, thehabes
*/

import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { _contextid, ObjectID, createExpressError, getAgentClaim, parseDocumentID, idNegotiation } from './utils.js'

/**
Expand Down
4 changes: 2 additions & 2 deletions controllers/crud.js → src/controllers/crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Basic CRUD operations for RERUM v1
* @author Claude Sonnet 4, cubap, thehabes
*/
import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { _contextid, idNegotiation, generateSlugId, ObjectID, createExpressError, getAgentClaim, parseDocumentID } from './utils.js'

/**
Expand Down
4 changes: 2 additions & 2 deletions controllers/delete.js → src/controllers/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Delete operations for RERUM v1
* @author Claude Sonnet 4, cubap, thehabes
*/
import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { createExpressError, getAgentClaim, parseDocumentID, getAllVersions, getAllDescendants } from './utils.js'

/**
Expand Down
4 changes: 2 additions & 2 deletions controllers/gog.js → src/controllers/gog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @author Claude Sonnet 4, cubap, thehabes
*/

import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { _contextid, ObjectID, createExpressError, getAgentClaim, parseDocumentID, idNegotiation } from './utils.js'

/**
Expand Down
4 changes: 2 additions & 2 deletions controllers/history.js → src/controllers/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @author Claude Sonnet 4, cubap, thehabes
*/

import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { _contextid, ObjectID, createExpressError, getAgentClaim, parseDocumentID, idNegotiation, getAllVersions, getAllAncestors, getAllDescendants } from './utils.js'

/**
Expand Down
4 changes: 2 additions & 2 deletions controllers/overwrite.js → src/controllers/overwrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @author Claude Sonnet 4, cubap, thehabes
*/

import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { _contextid, ObjectID, createExpressError, getAgentClaim, parseDocumentID, idNegotiation } from './utils.js'

/**
Expand Down
4 changes: 2 additions & 2 deletions controllers/patchSet.js → src/controllers/patchSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @author Claude Sonnet 4, cubap, thehabes
*/

import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { _contextid, ObjectID, createExpressError, getAgentClaim, parseDocumentID, idNegotiation, alterHistoryNext } from './utils.js'

/**
Expand Down
4 changes: 2 additions & 2 deletions controllers/patchUnset.js → src/controllers/patchUnset.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @author Claude Sonnet 4, cubap, thehabes
*/

import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { _contextid, ObjectID, createExpressError, getAgentClaim, parseDocumentID, idNegotiation, alterHistoryNext } from './utils.js'

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @author Claude Sonnet 4, cubap, thehabes
*/

import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { _contextid, ObjectID, createExpressError, getAgentClaim, parseDocumentID, idNegotiation, alterHistoryNext } from './utils.js'

/**
Expand Down
4 changes: 2 additions & 2 deletions controllers/putUpdate.js → src/controllers/putUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @author Claude Sonnet 4, cubap, thehabes
*/

import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { _contextid, ObjectID, createExpressError, getAgentClaim, parseDocumentID, idNegotiation, alterHistoryNext } from './utils.js'

/**
Expand Down
4 changes: 2 additions & 2 deletions controllers/release.js → src/controllers/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @author Claude Sonnet 4, cubap, thehabes
*/

import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'
import { _contextid, ObjectID, createExpressError, getAgentClaim, parseDocumentID, idNegotiation, generateSlugId, establishReleasesTree, healReleasesTree } from './utils.js'

/**
Expand Down
4 changes: 2 additions & 2 deletions controllers/search.js → src/controllers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Search ($search) operations for RERUM v1
* @author thehabes
*/
import { db } from '../database/index.js'
import utils from '../utils.js'
import { db } from '../db/index.js'
import utils from '../utils/index.js'
import { idNegotiation, createExpressError } from './utils.js'

/**
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions controllers/utils.js → src/controllers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Utility functions for RERUM controllers
* @author Claude Sonnet 4, cubap, thehabes
*/
import { newID, isValidID, db } from '../database/index.js'
import utils from '../utils.js'
import { newID, isValidID, db } from '../db/index.js'
import utils from '../utils/index.js'

const ObjectID = newID

Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions app.js → src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import dotenv from 'dotenv'
dotenv.config()
import logger from 'morgan'
import cors from 'cors'
import indexRouter from './routes/index.js'
import apiRouter from './routes/api-routes.js'
import clientRouter from './routes/client.js'
import _gog_fragmentsRouter from './routes/_gog_fragments_from_manuscript.js';
import _gog_glossesRouter from './routes/_gog_glosses_from_manuscript.js';
import rest from './rest.js'
import indexRouter from './services/index.js'
import apiRouter from './services/api-routes.js'
import clientRouter from './services/client.js'
import _gog_fragmentsRouter from './services/_gog_fragments_from_manuscript.js';
import _gog_glossesRouter from './services/_gog_glosses_from_manuscript.js';
import rest from './utils/rest.js'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
Expand Down Expand Up @@ -63,7 +63,7 @@ app.use(express.urlencoded({ extended: true }))
app.use(cookieParser())

//Publicly available scripts, CSS, and HTML pages.
app.use(express.static(path.join(__dirname, 'public')))
app.use(express.static(path.join(__dirname, '../public')))

/**
* For any request that comes through to the app, check whether or not we are in maintenance mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { jest } from "@jest/globals"
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

// Here is the auth mock so we get a req.user and the controller can function without a NPE.
const addAuth = (req, res, next) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { jest } from "@jest/globals"
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

// Here is the auth mock so we get a req.user and the controller can function without a NPE.
const addAuth = (req, res, next) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { jest } from "@jest/globals"
import express from "express"
import request from "supertest"
import { db } from '../../database/index.js'
import controller from '../../db-controller.js'
import { db } from '../../db/index.js'
import controller from '../db-controller.js'

const rerum_uri = `${process.env.RERUM_ID_PREFIX}123456`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import request from 'supertest'
//Fun fact, if you don't require app, you don't get coverage even though the tests run just fine.
import app from '../../app.js'
import app from '../../../src/index.js'
//This is so we can do Mongo specific things with the objects in this test, like actually remove them from the db.
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

//A super fun note. If you do request(app), the tests will fail due to race conditions.
//request = request(app)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { jest } from "@jest/globals"
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

// Here is the auth mock so we get a req.user and the controller can function without a NPE.
const addAuth = (req, res, next) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { jest } from "@jest/globals"
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

const routeTester = new express()
routeTester.use(express.json())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { jest } from "@jest/globals"
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

const routeTester = new express()
routeTester.use(express.json())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { jest } from "@jest/globals"
import dotenv from "dotenv"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

it("Functional '@id-id' negotiation on objects returned.", async () => {
let negotiate = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jest.mock('../../database/index.js', () => ({
}))

// Import controller after mocking
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

// Helper to add auth to requests
const addAuth = (req, res, next) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import request from 'supertest'
import app from '../../app.js'
import app from '../../../src/index.js'
import { jest } from '@jest/globals'

// Mock the database and auth modules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dotenv.config()
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

// Here is the auth mock so we get a req.user and the controller can function without a NPE.
const addAuth = (req, res, next) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { jest } from "@jest/globals"
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

const routeTester = new express()
routeTester.use(express.json())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { jest } from "@jest/globals"
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

// Here is the auth mock so we get a req.user so controller.create can function without a NPE.
const addAuth = (req, res, next) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dotenv.config()
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

// Here is the auth mock so we get a req.user and the controller can function without a NPE.
const addAuth = (req, res, next) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { jest } from "@jest/globals"
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

const routeTester = new express()
routeTester.use(express.json())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dotenv.config()
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

// Here is the auth mock so we get a req.user so controller.create can function without a NPE.
const addAuth = (req, res, next) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dotenv.config()
// Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
import express from "express"
import request from "supertest"
import controller from '../../db-controller.js'
import controller from '../db-controller.js'

// Here is the auth mock so we get a req.user so controller.create can function without a NPE.
const addAuth = (req, res, next) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import express from 'express'
const router = express.Router()
//This controller will handle all MongoDB interactions.
import controller from '../db-controller.js'
import auth from '../auth/index.js'
import controller from './db-controller.js'
import auth from '../config/index.js'

router.route('/')
.post(auth.checkJwt, controller._gog_fragments_from_manuscript)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import express from 'express'
const router = express.Router()
//This controller will handle all MongoDB interactions.
import controller from '../db-controller.js'
import auth from '../auth/index.js'
import controller from './db-controller.js'
import auth from '../config/index.js'

router.route('/')
.post(auth.checkJwt, controller._gog_glosses_from_manuscript)
Expand Down
File renamed without changes.
Loading