Skip to content

Commit

Permalink
feat: add API app based on Express
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Mar 10, 2024
1 parent caf3f82 commit ba34ad6
Show file tree
Hide file tree
Showing 25 changed files with 806 additions and 78 deletions.
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,30 @@ pnpm install
### Development

Start the API app:

```shell
pnpm dev:api
```

Start the web app:

```sh
pnpm dev
pnpm dev:web
```

### Build

Build the API app:

```sh
pnpm build:api
```

Build the web app:

```sh
pnpm build
pnpm build:wev
```

### Lint
Expand All @@ -56,6 +72,23 @@ pnpm lint
pnpm test
```

## Add Anchor

This project is compatible with the generators from [create-solana-dapp](https://npm.im/create-solana-dapp).

You can use it to generate an Anchor application:

```shell
pnpm add -D @solana-developers/preset-anchor
pnpm nx generate @solana-developers/preset-anchor:application anchor --dry-run
```

With this base set up, you can now add Anchor programs and tests to your project.

```shell
pnpm nx generate @solana-developers/preset-anchor:template --projectName anchor --directory anchor --template counter counter --dry-run
```

## License

MIT
18 changes: 18 additions & 0 deletions api/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
24 changes: 24 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file is generated by Nx.
#
# Build the docker image with `npx nx docker-build api`.
# Tip: Modify "docker-build" options in project.json to change docker build args.
#
# Run the container with `docker run -p 3000:3000 -t api`.
FROM docker.io/node:lts-alpine

ENV HOST=0.0.0.0
ENV PORT=3000

WORKDIR /app

RUN addgroup --system api && \
adduser --system -G api api

COPY dist/api api
RUN chown -R api:api .

# You can remove this install step if you build with `--bundle` option.
# The bundled output will include external dependencies.
RUN npm --prefix api --omit=dev -f install

CMD [ "node", "api" ]
11 changes: 11 additions & 0 deletions api/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'api',
preset: '../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../coverage/api',
}
78 changes: 78 additions & 0 deletions api/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"name": "api",
"$schema": "../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "api/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/esbuild:esbuild",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"platform": "node",
"outputPath": "dist/api",
"format": ["esm"],
"bundle": true,
"main": "api/src/main.ts",
"tsConfig": "api/tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "api/src/assets",
"output": "assets",
"ignore": [".gitkeep"]
}
],
"generatePackageJson": true,
"esbuildOptions": {
"sourcemap": true,
"outExtension": {
".js": ".js"
}
}
},
"configurations": {
"development": {},
"production": {
"generateLockfile": true,
"esbuildOptions": {
"sourcemap": false,
"outExtension": {
".js": ".js"
}
}
}
}
},
"serve": {
"executor": "@nx/js:node",
"defaultConfiguration": "development",
"options": {
"buildTarget": "api:build"
},
"configurations": {
"development": {
"buildTarget": "api:build:development"
},
"production": {
"buildTarget": "api:build:production"
}
}
},
"lint": {
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "api/jest.config.ts"
}
},
"docker-build": {
"dependsOn": ["build"],
"command": "docker build -f api/Dockerfile . -t api"
}
},
"tags": []
}
Binary file added api/src/assets/favicon.ico
Binary file not shown.
Binary file added api/src/assets/pubkey-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions api/src/assets/pubkey-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added api/src/assets/pubkey-logo-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions api/src/assets/pubkey-logo-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added api/src/assets/pubkey-logo-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ba34ad6

Please sign in to comment.