Skip to content

Commit

Permalink
merge: branch 'dev' into refactor/feed
Browse files Browse the repository at this point in the history
  • Loading branch information
omareloui committed Nov 20, 2024
2 parents 3ac441e + 6f35708 commit 9ee6844
Show file tree
Hide file tree
Showing 21 changed files with 4,850 additions and 2,299 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,20 @@ When you want to use prisma migrate dev without seeding, you can pass the --skip

Create a `.env` file in project root. If running with docker an additional `.env.dev` file is needed. Refer to below example for env variables:

```
```bash
PORT=9000
DATABASE_URL="postgresql://postgres:postgres@postgres:5432/claim"
ACCESS_SECRET=dPEBknfdAcx5bir34KnX2mATWZnvM4xF
REFRESH_SECRET=opdC0LNGrZWWF0jLrPJwhLPF8aew4l3L
ACCESS_SECRET='...'
REFRESH_SECRET='...'
AWS_ACCESS_KEY_ID='...'
AWS_SECRET_ACCESS_KEY='...'
AWS_STORAGE_BUCKET_NAME='...'
AWS_S3_REGION_NAME='...'
```

In `.env.dev`, change `DATABASE_URL` like below, everything else can be exactly like `.env`.

```
```bash
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/claim"
```

Expand Down
67 changes: 0 additions & 67 deletions docs/postman/trust_claim.json

This file was deleted.

138 changes: 134 additions & 4 deletions docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,45 @@ paths:
schema:
"$ref": "#/components/responses/Error"

"/api/claim/v2":
post:
tags:
- Claims
description: Create Claim (images as stream)
summary: Create Claim
security:
- bearerAuth: []
requestBody:
content:
multipart/form-data:
schema:
"$ref": "#/components/requestBodies/CreateClaimV2"
encoding:
images:
contentType: image/*
dto:
contentType: application/json

responses:
"201":
description: Created the claim successfully
content:
application/json:
schema:
"$ref": "#/components/schemas/CreatedClaim"
"401":
description: Unauthorized
content:
application/json:
schema:
"$ref": "#/components/responses/Error"
"500":
description: Invalid body/internal server error
content:
application/json:
schema:
"$ref": "#/components/responses/Error"

"/api/claim/{id}":
get:
tags:
Expand Down Expand Up @@ -435,12 +474,12 @@ components:
- OTHER
images:
type: array
required:
- url
- signature
- owner
items:
type: object
required:
- url
- signature
- owner
properties:
url:
type: string
Expand Down Expand Up @@ -479,6 +518,97 @@ components:
stars:
type: integer
nullable: true

CreateClaimV2:
type: object
required:
- dto
- images
properties:
images:
type: array
items:
type: string
format: binary
dto:
type: object
required:
- subject
- claim
- name
properties:
subject:
type: string
claim:
type: string
object:
type: string
nullable: true
statement:
type: string
nullable: true
aspect:
type: string
nullable: true
amt:
type: integer
nullable: true
name:
type: string
howKnown:
type: string
nullable: true
enum:
- FIRST_HAND
- SECOND_HAND
- WEB_DOCUMENT
- VERIFIED_LOGIN
- BLOCKCHAIN
- SIGNED_DOCUMENT
- PHYSICAL_DOCUMENT
- INTEGRATION
- RESEARCH
- OPINION
- OTHER
sourceURI:
type: string
nullable: true
effectiveDate:
type: string
format: date-time
nullable: true
confidence:
type: integer
nullable: true
claimAddress:
type: string
nullable: true
stars:
type: integer
nullable: true
images:
type: array
items:
type: object
properties:
metadata:
type: object
nullable: true
properties:
captian:
type: string
nullable: true
description:
type: string
nullable: true
effectiveDate:
type: string
format: date-time
nullable: true
digestMultibase:
type: string
nullable: true

responses:
Authentication:
type: object
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "concurrently \"tsc -w\" \"nodemon build/index.js\"",
"inspect": "concurrently \"tsc -w\" \"nodemon --inspect build/index.js\"",
"dev:watch": "tsc -w",
"dev:watch": "nodemon -w './src/**/*' -w 'docs/**/*' src/index.ts",
"build": "tsc",
"start": "node build/index.js",
"create:model": "rm build/ceramic_model/create_model.mjs; tsc --project src/ceramic_model/tsconfig.datamodel.json && renamer --find \".js\" --replace \".mjs\" build/ceramic_model/create_model.js; node --experimental-json-modules build/ceramic_model/create_model.mjs",
Expand All @@ -16,11 +16,14 @@
"prisma:studio": "dotenv -e .env.dev -- npx prisma studio",
"format": "prettier -w ./src/**/* -w ./docs/**/* -w ./*.md -w ./**/*.md",
"lint": "eslint . --fix",
"format": "prettier -w ./src/**/*",
"test": "jest"
},
"author": "",
"license": "ISC",
"dependencies": {
"@aws-sdk/client-s3": "^3.658.0",
"@aws-sdk/s3-request-presigner": "^3.658.1",
"@ceramicnetwork/http-client": "^2.0.4",
"@glazed/datamodel": "^0.3.0",
"@glazed/devtools": "^0.2.0",
Expand All @@ -39,8 +42,10 @@
"key-did-provider-ed25519": "^2.0.0",
"key-did-resolver": "^2.0.4",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"sharp": "^0.33.5",
"uint8arrays": "^3.0.0",
"yaml": "^2.5.1",
"ulid": "^2.3.0",
"zod": "^3.21.4"
},
"engines": {
Expand All @@ -58,6 +63,7 @@
"@types/jest": "^29.4.0",
"@types/jsonwebtoken": "^8.5.8",
"@types/morgan": "^1.9.3",
"@types/multer": "^1.4.12",
"@types/node": "^17.0.45",
"@types/supertest": "^2.0.12",
"@types/swagger-ui-express": "^4.1.3",
Expand Down
26 changes: 26 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { z } from "zod";

const schema = z.object({
s3: z.object({
accessKeyId: z.string(),
secretAccessKey: z.string(),
region: z.string(),
bucketName: z.string(),
}),
});

let config: z.infer<typeof schema>;
try {
config = schema.parse({
s3: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: process.env.AWS_S3_REGION_NAME,
bucketName: process.env.AWS_STORAGE_BUCKET_NAME,
},
});
} catch (e) {
console.error("Error parsing the configuration:", e);
}

export { config };
Loading

0 comments on commit 9ee6844

Please sign in to comment.