File tree Expand file tree Collapse file tree 5 files changed +134
-1
lines changed Expand file tree Collapse file tree 5 files changed +134
-1
lines changed Original file line number Diff line number Diff line change 2323 "frontend/build/**" : true ,
2424 "frontend/src/tailwind.output.css" : true
2525 },
26- "typescript.tsdk" : " ./frontend/node_modules/typescript/lib"
26+ "typescript.tsdk" : " ./frontend/node_modules/typescript/lib" ,
27+ "deno.enable" : true ,
28+ "deno.lint" : true ,
29+ "deno.unstable" : true ,
30+ "deno.import_intellisense_origins" : {
31+ "https://deno.land" : true
32+ },
33+ "deno.import_intellisense_autodiscovery" : true
2734}
Original file line number Diff line number Diff line change 1+ FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.31
2+
3+ ENV DENO_VERSION=1.4.5
4+
5+ RUN apk add --virtual .download --no-cache curl \
6+ && curl -fsSL https://github.com/denoland/deno/releases/download/v${DENO_VERSION}/deno-x86_64-unknown-linux-gnu.zip \
7+ --output deno.zip \
8+ && unzip deno.zip \
9+ && rm deno.zip \
10+ && chmod 777 deno \
11+ && mv deno /bin/deno \
12+ && apk del .download
13+
14+ RUN addgroup -g 1993 -S deno \
15+ && adduser -u 1993 -S deno -G deno \
16+ && mkdir /deno-dir/ \
17+ && chown deno:deno /deno-dir/
18+
19+ ENV DENO_DIR /deno-dir/
20+ ENV DENO_INSTALL_ROOT /usr/local
21+
22+ # The port that your application listens to.
23+ EXPOSE 1993
24+
25+ WORKDIR /app
26+
27+ # Prefer not to run as root.
28+ USER deno
29+
30+ # Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
31+ # Ideally cache deps.ts will download and compile _all_ external files used in main.ts.
32+ COPY deps.ts .
33+ RUN deno cache deps.ts
34+
35+ # These steps will be re-run upon each file change in your working directory:
36+ ADD . .
37+ # Compile the main app so that it doesn't need to be compiled each startup/entry.
38+ RUN deno cache main.ts
39+
40+ CMD ["deno" , "run" , "--allow-net" , "main.ts" ]
Original file line number Diff line number Diff line change 1+ export {
2+ Application ,
3+ Router ,
4+ RouterContext ,
5+ } from "https://deno.land/x/oak@v6.3.1/mod.ts" ;
6+ export {
7+ applyGraphQL ,
8+ gql ,
9+ GQLError ,
10+ } from "https://deno.land/x/oak_graphql@0.6.2/mod.ts" ;
Original file line number Diff line number Diff line change 1+ import { Application } from "./deps.ts" ;
2+ import { applyGraphQL , gql } from "./deps.ts" ;
3+
4+ const app = new Application ( ) ;
5+
6+ const types = gql `
7+ type Dino {
8+ name: String
9+ image: String
10+ }
11+ input DinoInput {
12+ name: String
13+ image: String
14+ }
15+ type ResolveType {
16+ done: Boolean
17+ }
18+ type Query {
19+ getDino(name: String): Dino
20+ getDinos: [Dino!]!
21+ }
22+ type Mutation {
23+ addDino(input: DinoInput!): ResolveType!
24+ }
25+ ` ;
26+
27+ const dinos = [
28+ {
29+ name : "Tyrannosaurus Rex" ,
30+ image : "🦖" ,
31+ } ,
32+ ] ;
33+
34+ const resolvers = {
35+ Query : {
36+ getDino : ( _ , { name } ) => {
37+ const dino = dinos . find ( ( dino ) => dino . name . includes ( name ) ) ;
38+ if ( ! dino ) {
39+ throw new Error ( `No dino name includes ${ name } ` ) ;
40+ }
41+ return dino ;
42+ } ,
43+ getDinos : ( ) => {
44+ return dinos ;
45+ } ,
46+ } ,
47+ Mutation : {
48+ addDino : ( _ , { input : { name, image } } ) => {
49+ dinos . push ( {
50+ name,
51+ image,
52+ } ) ;
53+ return {
54+ done : true ,
55+ } ;
56+ } ,
57+ } ,
58+ } ;
59+
60+ const GraphQLService = applyGraphQL ( {
61+ typeDefs : types ,
62+ resolvers : resolvers ,
63+ } ) ;
64+
65+ app . use ( GraphQLService . routes ( ) , GraphQLService . allowedMethods ( ) ) ;
66+
67+ console . log ( "Server start at http://localhost:1993" ) ;
68+ await app . listen ( { port : 1993 } ) ;
Original file line number Diff line number Diff line change 1+ version : " 3.8"
2+ services :
3+ deno-graphql :
4+ build :
5+ context : ./deno
6+ dockerfile : Dockerfile
7+ ports :
8+ - " 1993:1993"
You can’t perform that action at this time.
0 commit comments