Skip to content

Commit

Permalink
update deps + add new api (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0ece authored May 7, 2024
1 parent 50648dc commit 8a6fae5
Show file tree
Hide file tree
Showing 37 changed files with 11,465 additions and 9,288 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr_test_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
branches: ["main"]
paths:
- "api/**"
- "api_v0/**"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down Expand Up @@ -47,4 +47,4 @@ jobs:
- name: Install dependencies and run tests
shell: bash
run: |
cd api/ && pnpm install && pnpm run test
cd api_v0/ && pnpm install && pnpm run test
1 change: 1 addition & 0 deletions anchor/Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[toolchain]
anchor_version = "0.29.0"

[features]
seeds = false
Expand Down
29 changes: 15 additions & 14 deletions anchor/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions anchor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ codegen-units = 1
[workspace.dependencies]
anchor-lang = { version = "0.29.0", features = ["init-if-needed"] }
anchor-spl = "0.29.0"
solana-program = "=1.18.7"
solana-program = "=1.18.12"

anchor-gen = "0.3.1"
spl-token = "=4.0.1"
anchor-gen = "0.3.0"
spl-token-2022 = "3.0.2"
spl-associated-token-account = "3.0.2"
spl-token-metadata-interface = "0.3.3"
spl-transfer-hook-interface = "0.6.3"
pyth-sdk-solana = "0.10.1"

drift = { path = "./deps/drift" }
marinade = { path = "./deps/marinade" }
5 changes: 4 additions & 1 deletion anchor/programs/glam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ devnet = []
anchor-lang = { workspace = true }
anchor-spl = { workspace = true }
solana-program = { workspace = true }

spl-token = { workspace = true }
spl-associated-token-account = { workspace = true }
spl-token-2022 = { workspace = true }
spl-associated-token-account = { workspace = true }
spl-token-metadata-interface = { workspace = true }
spl-transfer-hook-interface = { workspace = true }
pyth-sdk-solana = { workspace = true }

drift = { workspace = true }
marinade = { workspace = true }
18 changes: 18 additions & 0 deletions api-e2e/.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": {}
}
]
}
19 changes: 19 additions & 0 deletions api-e2e/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-disable */
export default {
displayName: "api-e2e",
preset: "../jest.preset.js",
globalSetup: "<rootDir>/src/support/global-setup.ts",
globalTeardown: "<rootDir>/src/support/global-teardown.ts",
setupFiles: ["<rootDir>/src/support/test-setup.ts"],
testEnvironment: "node",
transform: {
"^.+\\.[tj]s$": [
"ts-jest",
{
tsconfig: "<rootDir>/tsconfig.spec.json"
}
]
},
moduleFileExtensions: ["ts", "js", "html"],
coverageDirectory: "../coverage/api-e2e"
};
19 changes: 19 additions & 0 deletions api-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "api-e2e",
"$schema": "../node_modules/nx/schemas/project-schema.json",
"implicitDependencies": ["api"],
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{e2eProjectRoot}"],
"options": {
"jestConfig": "api-e2e/jest.config.ts",
"passWithNoTests": true
}
},
"lint": {
"executor": "@nx/eslint:lint"
}
}
}
10 changes: 10 additions & 0 deletions api-e2e/src/api/api.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import axios from "axios";

describe("GET /", () => {
it("should return a message", async () => {
const res = await axios.get(`/`);

expect(res.status).toBe(200);
expect(res.data).toEqual({ message: "Hello API" });
});
});
10 changes: 10 additions & 0 deletions api-e2e/src/support/global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */
var __TEARDOWN_MESSAGE__: string;

module.exports = async function () {
// Start services that that the app needs to run (e.g. database, docker-compose, etc.).
console.log("\nSetting up...\n");

// Hint: Use `globalThis` to pass variables to global teardown.
globalThis.__TEARDOWN_MESSAGE__ = "\nTearing down...\n";
};
7 changes: 7 additions & 0 deletions api-e2e/src/support/global-teardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable */

module.exports = async function () {
// Put clean up logic here (e.g. stopping services, docker-compose, etc.).
// Hint: `globalThis` is shared between setup and teardown.
console.log(globalThis.__TEARDOWN_MESSAGE__);
};
10 changes: 10 additions & 0 deletions api-e2e/src/support/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */

import axios from "axios";

module.exports = async function () {
// Configure axios for tests to use.
const host = process.env.HOST ?? "localhost";
const port = process.env.PORT ?? "3000";
axios.defaults.baseURL = `http://${host}:${port}`;
};
13 changes: 13 additions & 0 deletions api-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"esModuleInterop": true
}
}
9 changes: 9 additions & 0 deletions api-e2e/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["jest.config.ts", "src/**/*.ts"]
}
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": {}
}
]
}
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"
};
52 changes: 52 additions & 0 deletions api/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "api",
"$schema": "../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "api/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"target": "node",
"compiler": "tsc",
"outputPath": "dist/api",
"main": "api/src/main.ts",
"tsConfig": "api/tsconfig.app.json",
"assets": ["api/src/assets"],
"webpackConfig": "api/webpack.config.js"
},
"configurations": {
"development": {},
"production": {}
}
},
"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"
}
}
},
"tags": []
}
Empty file added api/src/assets/.gitkeep
Empty file.
21 changes: 21 additions & 0 deletions api/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This is not a production server yet!
* This is only a minimal backend to get started.
*/

import express from "express";
import * as path from "path";

const app = express();

app.use("/assets", express.static(path.join(__dirname, "assets")));

app.get("/api", (req, res) => {
res.send({ message: "Welcome to api!" });
});

const port = process.env.PORT || 3333;
const server = app.listen(port, () => {
console.log(`Listening at http://localhost:${port}/api`);
});
server.on("error", console.error);
10 changes: 10 additions & 0 deletions api/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc",
"module": "commonjs",
"types": ["node", "express"]
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}
Loading

0 comments on commit 8a6fae5

Please sign in to comment.