File tree Expand file tree Collapse file tree 6 files changed +4006
-0
lines changed Expand file tree Collapse file tree 6 files changed +4006
-0
lines changed Original file line number Diff line number Diff line change 4646 "test:env:node-ts" : " yarn --cwd tests/env/typescript-node start" ,
4747 "test:env:nodejs" : " node tests/env/node/index.js" ,
4848 "test:env:esm" : " yarn --cwd tests/env/esm && yarn --cwd tests/env/esm start" ,
49+ "test:env:nitro-app" : " yarn build && yarn --cwd tests/env/nitro-app test" ,
4950 "size" : " node scripts/file-size ./dist/bundles/meilisearch.esm.min.js ./dist/bundles/meilisearch.umd.min.js" ,
5051 "style" : " yarn lint" ,
5152 "style:fix" : " yarn lint:fix" ,
Original file line number Diff line number Diff line change 1+ node_modules
2+ * .log *
3+ .nitro
4+ .cache
5+ .output
Original file line number Diff line number Diff line change 1+ {
2+ "private" : true ,
3+ "scripts" : {
4+ "test" : " jest" ,
5+ "dev" : " npx nitropack dev" ,
6+ "build" : " npx nitropack build" ,
7+ "preview" : " node .output/server/index.mjs"
8+ },
9+ "dependencies" : {
10+ "meilisearch" : " file:../../../" ,
11+ "nitropack" : " latest"
12+ },
13+ "devDependencies" : {
14+ "jest" : " 29.5.0"
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ import { MeiliSearch } from 'meilisearch'
2+
3+ const meilisearch = new MeiliSearch ( {
4+ host : 'http://localhost:7700' ,
5+ apiKey : 'masterKey' ,
6+ } )
7+
8+ export default defineEventHandler ( async ( ) => {
9+ try {
10+ const health = await meilisearch . isHealthy ( )
11+
12+ return { health }
13+ } catch ( error ) {
14+ throw createError ( {
15+ statusCode : 500 ,
16+ statusMessage : 'Unexpected Error' ,
17+ } )
18+ }
19+ } )
Original file line number Diff line number Diff line change 1+ const { execSync, spawn } = require ( 'child_process' )
2+
3+ let server
4+
5+ beforeAll ( ( ) => {
6+ execSync ( 'yarn' , [ 'build' ] , { env : process . env } )
7+
8+ server = spawn ( 'node' , [ '.output/server/index.mjs' ] )
9+ } )
10+
11+ describe ( 'Meilisearch JS w/ Nitro App Server Browser test' , ( ) => {
12+ it ( 'Should have created an index and displayed it' , async ( ) => {
13+ await new Promise ( ( next ) => {
14+ server . stdout . on ( 'data' , ( ) => {
15+ next ( )
16+ server . stdout . removeAllListeners ( 'data' )
17+ } )
18+ } )
19+ const response = await fetch ( 'http://[::]:3000' )
20+ const data = await response . json ( )
21+
22+ expect ( data . health ) . toBe ( true )
23+ } )
24+
25+ afterAll ( ( ) => {
26+ server . kill ( )
27+ } )
28+ } )
You can’t perform that action at this time.
0 commit comments