Skip to content

Commit

Permalink
refactor: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
minenwerfer committed Mar 6, 2024
1 parent 87af051 commit 8969427
Show file tree
Hide file tree
Showing 23 changed files with 1,248 additions and 541 deletions.
539 changes: 539 additions & 0 deletions api/aeria-sdk.d.ts

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions api/aeria.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// this file will be overwritten
import type {} from '@aeriajs/types'

declare global {
type UnpackCollections<TCollections> = {
[P in keyof TCollections]: TCollections[P] extends infer Candidate
? Candidate extends (...args: any[]) => infer Coll
? Coll
: Candidate
: never
}

type Collections = typeof import('.') extends infer EntrypointModule
? 'collections' extends keyof EntrypointModule
? UnpackCollections<EntrypointModule['collections']>
: 'default' extends keyof EntrypointModule
? EntrypointModule['default'] extends infer Entrypoint
? 'options' extends keyof Entrypoint
? 'collections' extends keyof Entrypoint['options']
? UnpackCollections<Entrypoint['options']['collections']>
: never
: never
: never
: never
: never
}

declare module 'aeria' {
import type { Context } from 'aeria'
export const useAeria: () => Promise<Context>
export const aeria: Context
}
//
21 changes: 15 additions & 6 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@
"main": "dist/index.js",
"types": "src/index.ts",
"scripts": {
"build": "sonata-build -ci",
"migrate": "sonata-build -m",
"dev": "sonata-build -w",
"start": "node -r sonata-api/loader ./release/index.js"
"build": "aeria -ci",
"migrate": "aeria -m",
"dev": "aeria -w",
"start": "node -r aeria/loader ./release/index.js"
},
"aeriaSdk": {
"apiUrl": {
"development": "http://localhost:3000/api"
},
"storage": {
"strategy": "localStorage",
"namespace": "aeria"
}
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"sonata-api": "latest"
"aeria": "latest"
},
"devDependencies": {
"sonata-build": "latest"
"aeria-build": "latest"
}
}
2 changes: 1 addition & 1 deletion api/sonata-api.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// this file will be overwritten
import type {} from '@sonata-api/types'
import type {} from '@aeriajs/types'

declare global {
type UnpackCollections<TCollections> = {
Expand Down
2 changes: 1 addition & 1 deletion api/src/collections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export {
log,
resourceUsage,

} from 'sonata-api'
} from 'aeria'

5 changes: 4 additions & 1 deletion api/src/collections/pizza/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineCollection, get, getAll, insert, remove } from 'sonata-api'
import { defineCollection, get, getAll, insert, remove } from 'aeria'

export const pizza = defineCollection({
description: {
Expand All @@ -9,6 +9,9 @@ export const pizza = defineCollection({
name: {
type: 'string',
},
flavor: {
literal: 'cheese',
},
price: {
type: 'number',
},
Expand Down
2 changes: 1 addition & 1 deletion api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { init, createRouter } from 'sonata-api'
import { init, createRouter } from 'aeria'
import { pizzaRoutes } from './routes/index.js'
export * as collections from './collections/index.js'

Expand Down
52 changes: 51 additions & 1 deletion api/src/routes/pizzaRoutes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRouter } from 'sonata-api'
import { createRouter } from 'aeria'

export const pizzaRoutes = createRouter()

Expand All @@ -11,3 +11,53 @@ pizzaRoutes.GET('/topRatedPizzas', (context) => {
})
})

pizzaRoutes.POST('/shampoo123', (context) => {
return [
{
name: context.request.payload.name,
now: new Date(),
age: 24,
},
]
// return context.collections.pizza.functions.getAll({
// limit: 5,
// sort: {
// rating: -1,
// },
// })
}, {
payload: {
type: 'object',
properties: {
name: {
type: 'string',
},
type: {
enum: [
'dog',
'alien',
'human',
],
},
},
},
response: {
type: 'array',
items: {
type: 'object',
properties: {
name: {
type: 'string',
},
age: {
type: 'number',
},
now: {
type: 'string',
format: 'date-time',
},
},
},
},
})

9 changes: 7 additions & 2 deletions api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"extends": "sonata-build/config/tsconfig.json",
"extends": "aeria-build/config/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"preserveSymlinks": true
}
},
"include": [
"src",
"@types/*.d.ts",
"sonata-api.d.ts"
]
}
Loading

0 comments on commit 8969427

Please sign in to comment.