1
1
import { VulcanBuilder , IBuildOptions } from '@vulcan-sql/build' ;
2
2
import { VulcanServer , ServeConfig , APIProviderType } from '@vulcan-sql/serve' ;
3
3
import * as path from 'path' ;
4
+ import * as supertest from 'supertest' ;
4
5
5
6
const projectConfig : ServeConfig & IBuildOptions = {
6
7
name : 'example project 1' ,
@@ -24,12 +25,35 @@ const projectConfig: ServeConfig & IBuildOptions = {
24
25
folderPath : __dirname ,
25
26
} ,
26
27
types : [ APIProviderType . RESTFUL ] ,
28
+ executor : {
29
+ type : 'pg-mem' ,
30
+ } ,
31
+ extensions : {
32
+ mockEx : path . resolve ( __dirname , '..' , 'mockExtensions' ) ,
33
+ } ,
34
+ 'rate-limit' : {
35
+ options : { interval : { min : 1 } , max : 10000 } ,
36
+ } ,
27
37
} ;
28
38
29
- it ( 'Example1: Build and server should work' , async ( ) => {
39
+ let server : VulcanServer ;
40
+
41
+ afterEach ( async ( ) => {
42
+ await server . close ( ) ;
43
+ } ) ;
44
+
45
+ it ( 'Example1: Build and serve should work' , async ( ) => {
30
46
const builder = new VulcanBuilder ( ) ;
31
47
await builder . build ( projectConfig ) ;
32
- const server = new VulcanServer ( projectConfig ) ;
33
- await server . start ( 3000 ) ;
34
- await server . close ( ) ;
48
+ server = new VulcanServer ( projectConfig ) ;
49
+ const httpServer = await server . start ( 3000 ) ;
50
+
51
+ const agent = supertest ( httpServer ) ;
52
+ const result = await agent . get (
53
+ '/user?id=436193eb-f686-4105-ad7b-b5945276c14a'
54
+ ) ;
55
+ expect ( result . body ) . toContainEqual ( {
56
+ id : '436193eb-f686-4105-ad7b-b5945276c14a' ,
57
+ name : 'ivan' ,
58
+ } ) ;
35
59
} , 10000 ) ;
0 commit comments