11import arc from "@architect/functions" ;
2- import path from "path" ;
2+ import { promisify } from "util" ;
3+ import path , { resolve } from "path" ;
34import fs from "fs" ;
45import { ApolloServer } from "apollo-server-lambda" ;
56import {
67 ApolloServerPluginLandingPageProductionDefault ,
78 ApolloServerPluginLandingPageLocalDefault ,
89} from "apollo-server-core" ;
9- import resolvers from "../src/resolvers/index.js" ;
1010
1111const __dirname = path . resolve ( ) ;
1212
13+ const readdir = promisify ( fs . readdir ) ;
14+ async function * getFiles ( dir ) {
15+ const dirents = await readdir ( dir , { withFileTypes : true } ) ;
16+ for ( const dirent of dirents ) {
17+ const res = resolve ( dir , dirent . name ) ;
18+ if ( dirent . isDirectory ( ) ) {
19+ yield * getFiles ( res ) ;
20+ } else {
21+ yield res ;
22+ }
23+ }
24+ }
25+
26+ ( async ( ) => {
27+ try {
28+ for await ( const f of getFiles ( "../../var" ) ) {
29+ console . log ( f ) ;
30+ }
31+ } catch ( err ) {
32+ console . error ( err ) ;
33+ }
34+ } ) ( ) ;
35+
36+ console . info ( "__dirname" , __dirname ) ;
37+
38+ import resolvers from "../resolvers/index.js" ;
39+
1340const ServerHandler = new ApolloServer ( {
1441 typeDefs : fs . readFileSync (
15- path . join ( __dirname , "../src/ " , "schema.graphql" ) ,
42+ path . join ( __dirname , "../" , "schema.graphql" ) ,
1643 "utf8"
1744 ) ,
1845 resolvers,
@@ -24,6 +51,8 @@ const ServerHandler = new ApolloServer({
2451 introspection : true ,
2552} ) . createHandler ( ) ;
2653
54+ // TODO :: handling timeouts
55+
2756export async function handler ( event , context , callback ) {
2857 try {
2958 const body = arc . http . helpers . bodyParser ( event ) ;
0 commit comments