-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
433 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"cSpell.words": ["cblock", "Xverse"] | ||
"cSpell.words": ["cblock", "tapkey", "Xverse"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@0xflick/app-graphql-backend", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"type": "module", | ||
"license": "MIT", | ||
"scripts": { | ||
"start:dev": "node --loader ts-node/esm src/index.ts | bunyan", | ||
"dev": "ts-node-dev --inspect -r dotenv/config -- src/index.ts | bunyan" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.4.0", | ||
"bunyan": "^1.8.15", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.1.6" | ||
}, | ||
"dependencies": { | ||
"@graphql-tools/load-files": "^7.0.0", | ||
"apollo-server": "^3.12.0", | ||
"apollo-server-core": "^3.12.0", | ||
"dotenv": "^16.3.1", | ||
"graphql": "^16.7.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { ApolloServer } from "apollo-server"; | ||
import { ApolloServerPluginLandingPageGraphQLPlayground } from "apollo-server-core"; | ||
import { | ||
createGraphqlApplication, | ||
createContext, | ||
} from "@0xflick/ordinals-graphql"; | ||
import { | ||
deserializeSessionCookie, | ||
expireSessionCookie, | ||
serializeSessionCookie, | ||
} from "@0xflick/ordinals-backend"; | ||
|
||
const app = await createGraphqlApplication(); | ||
const executor = app.createApolloExecutor(); | ||
const schema = app.schema; | ||
|
||
const apolloServer = new ApolloServer({ | ||
schema, | ||
executor, | ||
context: ({ req, res }) => { | ||
return { | ||
...createContext(), | ||
getToken: () => { | ||
const cookieToken = deserializeSessionCookie(req.headers.cookie); | ||
if (cookieToken) { | ||
return cookieToken; | ||
} | ||
const authHeader = req.headers.authorization; | ||
if (authHeader) { | ||
const [type, token] = authHeader.split(" "); | ||
if (type === "Bearer") { | ||
return token; | ||
} | ||
} | ||
return null; | ||
}, | ||
setToken: (token: string) => { | ||
res.setHeader("set-cookie", serializeSessionCookie(token, "/")); | ||
}, | ||
clearToken: () => { | ||
res.setHeader("set-cookie", expireSessionCookie("/")); | ||
}, | ||
}; | ||
}, | ||
cors: { | ||
origin: [ | ||
"http://localhost:3000", | ||
"http://localhost:3001", | ||
"http://127.0.0.1:3000", | ||
], | ||
credentials: true, | ||
}, | ||
introspection: true, | ||
plugins: [ApolloServerPluginLandingPageGraphQLPlayground], | ||
}); | ||
|
||
const { url } = await apolloServer.listen(); | ||
console.log(`🚀 Server ready at ${url}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"extends": "@0xflick/tsconfig/tsconfig.base.json", | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"lib": ["esnext"], | ||
"module": "Node16", | ||
"outDir": "./dist", | ||
"composite": true, | ||
"incremental": true, | ||
"paths": { | ||
"@0xflick/ordinals-graphql": ["../../packages/graphql/src/index"], | ||
"@0xflick/ordinals-backend": ["../../packages/backend/src/index"], | ||
"@0xflick/ordinals-models": ["../../packages/models/src/index"] | ||
}, | ||
"plugins": [] | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["./node_modules"], | ||
"references": [ | ||
{ | ||
"path": "../../packages/graphql" | ||
}, | ||
{ | ||
"path": "../../packages/backend" | ||
}, | ||
{ | ||
"path": "../../packages/models" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,13 @@ | ||
import type { IFundingDao } from "../dao/funding.js"; | ||
import { tableNames } from "../utils/config.js"; | ||
import { createDb } from "./create.js"; | ||
import { | ||
FundingDao, | ||
TFundingCollectionReturner, | ||
TFundingItemReturner, | ||
} from "./funding.js"; | ||
import { FundingDao } from "./funding.js"; | ||
|
||
export function createDynamoDbFundingDao< | ||
ItemInputType extends Record<string, any> = {}, | ||
ItemMeta extends Record<string, any> = {}, | ||
ItemReturnType = any, | ||
CollectionInputType extends Record<string, any> = {}, | ||
CollectionMeta extends Record<string, any> = {}, | ||
CollectionReturnType = any | ||
>({ | ||
itemFundingUpdater, | ||
collectionFundingUpdater, | ||
}: { | ||
itemFundingUpdater: TFundingItemReturner<ItemInputType, ItemReturnType>; | ||
collectionFundingUpdater: TFundingCollectionReturner< | ||
CollectionInputType, | ||
CollectionReturnType | ||
>; | ||
}): IFundingDao< | ||
ItemInputType, | ||
ItemMeta, | ||
ItemReturnType, | ||
CollectionInputType, | ||
CollectionMeta, | ||
CollectionReturnType | ||
> { | ||
CollectionMeta extends Record<string, any> = {} | ||
>(): IFundingDao<ItemMeta, CollectionMeta> { | ||
const allTableNames = tableNames.get(); | ||
FundingDao.TABLE_NAME = allTableNames.funding ?? FundingDao.TABLE_NAME; | ||
return new FundingDao< | ||
ItemInputType, | ||
ItemMeta, | ||
ItemReturnType, | ||
CollectionInputType, | ||
CollectionMeta, | ||
CollectionReturnType | ||
>({ | ||
client: createDb(), | ||
itemFundingUpdater, | ||
collectionFundingUpdater, | ||
}); | ||
return new FundingDao<ItemMeta, CollectionMeta>(createDb()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.