Skip to content

Commit

Permalink
breaking: migrate to cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
Eomm committed Sep 24, 2023
1 parent 59a2bd6 commit 60c018d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 32 deletions.
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import fp from 'fastify-plugin'
import * as Orama from '@orama/orama'
'use strict'

import PersistenceInMemory from './lib/persistence/in-memory.js'
import PersistenceInFile from './lib/persistence/in-file.js'
const fp = require('fastify-plugin')
const Orama = require('@orama/orama')

const PersistenceInMemory = require('./lib/persistence/in-memory.js')
const PersistenceInFile = require('./lib/persistence/in-file.js')

const SKIP_METHODS = [
'create'
Expand Down Expand Up @@ -52,14 +54,12 @@ async function fastifyOrama (fastify, options) {
fastify.decorate('orama', oramaApi)
}

export default fp(fastifyOrama, {
module.exports = fp(fastifyOrama, {
fastify: '4.x',
name: 'fastify-orama'
})

export {
fastifyOrama,
PersistenceInMemory,
PersistenceInFile,
oramaInternals
}
module.exports.fastifyOrama = fastifyOrama
module.exports.PersistenceInMemory = PersistenceInMemory
module.exports.PersistenceInFile = PersistenceInFile
module.exports.oramaInternals = oramaInternals
10 changes: 6 additions & 4 deletions lib/persistence/in-file.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import path from 'node:path'
import { existsSync } from 'node:fs'
import { restoreFromFile, persistToFile } from '@orama/plugin-data-persistence/server'
'use strict'

const path = require('node:path')
const { existsSync } = require('node:fs')
const { restoreFromFile, persistToFile } = require('@orama/plugin-data-persistence/server')

class PersistenceInFile {
constructor (options = {}) {
Expand Down Expand Up @@ -30,4 +32,4 @@ class PersistenceInFile {
}
}

export default PersistenceInFile
module.exports = PersistenceInFile
6 changes: 4 additions & 2 deletions lib/persistence/in-memory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { restore, persist } from '@orama/plugin-data-persistence'
'use strict'

const { restore, persist } = require('@orama/plugin-data-persistence')

class PersistenceInMemory {
constructor (options) {
Expand All @@ -18,4 +20,4 @@ class PersistenceInMemory {
}
}

export default PersistenceInMemory
module.exports = PersistenceInMemory
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.7.0",
"description": "Orama search-engine plugin for Fastify",
"main": "index.js",
"type": "module",
"types": "index.d.ts",
"author": {
"name": "Mateo Nunez",
Expand Down
8 changes: 4 additions & 4 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict'

import { it } from 'node:test'
import { ok, strictEqual } from 'node:assert'
import Fastify from 'fastify'
import fastifyOrama from '../index.js'
const { it } = require('node:test')
const { ok, strictEqual } = require('node:assert')
const Fastify = require('fastify')
const fastifyOrama = require('../index.js')

it('Should register correctly fastifyOrama plugin', async () => {
const fastify = Fastify()
Expand Down
8 changes: 4 additions & 4 deletions test/orama-proxy.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict'

import { it } from 'node:test'
import { ok, strictEqual } from 'node:assert'
import Fastify from 'fastify'
import { fastifyOrama, oramaInternals } from '../index.js'
const { it } = require('node:test')
const { ok, strictEqual } = require('node:assert')
const Fastify = require('fastify')
const { fastifyOrama, oramaInternals } = require('../index.js')

it('Should expose all the Orama APIs', async () => {
const fastify = Fastify()
Expand Down
14 changes: 8 additions & 6 deletions test/persistence.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { describe, it } from 'node:test'
import { strictEqual, match } from 'node:assert'
import Fastify from 'fastify'
import { fastifyOrama, PersistenceInMemory, PersistenceInFile } from '../index.js'
import { create, insert } from '@orama/orama'
import { persistToFile } from '@orama/plugin-data-persistence/server'
'use strict'

const { describe, it } = require('node:test')
const { strictEqual, match } = require('node:assert')
const Fastify = require('fastify')
const { fastifyOrama, PersistenceInMemory, PersistenceInFile } = require('../index.js')
const { create, insert } = require('@orama/orama')
const { persistToFile } = require('@orama/plugin-data-persistence/server')

async function buildFakeDb (filePath, format) {
const db = await create({
Expand Down

0 comments on commit 60c018d

Please sign in to comment.