Skip to content

Commit

Permalink
Merge pull request #1 from minenwerfer/master
Browse files Browse the repository at this point in the history
Refactor style
  • Loading branch information
SamCaliman authored Jul 29, 2024
2 parents 0dd58a5 + 1165250 commit 852d03e
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 424 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
production.env
dist
node_modules
api/release
**/.aeria/out

110 changes: 0 additions & 110 deletions api/.aeria/aeria-sdk.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,84 +87,6 @@ declare type MirrorDescriptions = {
}
}
},
"pet": {
"$id": "pet",
"properties": {
"name": {
"type": "string"
},
"type": {
"enum": [
"dog",
"cat"
]
},
"picture": {
"$ref": "file",
"accept": [
"image/*"
],
"indexes": [
"name",
"link",
"type"
]
},
"created_at": {
"type": "string",
"format": "date-time",
"noForm": true,
"readOnly": true,
"isTimestamp": true
},
"updated_at": {
"type": "string",
"format": "date-time",
"noForm": true,
"readOnly": true,
"isTimestamp": true
}
},
"icon": "dog",
"presets": [
"crud"
],
"indexes": [
"name"
],
"actions": {
"spawnAdd": {
"label": "action.add",
"event": "spawnAdd",
"icon": "plus",
"button": true,
"translate": true
}
},
"individualActions": {
"spawnEdit": {
"label": "action.edit",
"event": "spawnEdit",
"icon": "pencil-simple",
"translate": true
},
"viewItem": {
"label": "action.view",
"icon": "eye",
"translate": true,
"route": {
"name": "/dashboard/:collection/:id",
"setItem": true
}
},
"remove": {
"label": "action.remove",
"icon": "trash",
"ask": true,
"translate": true
}
}
},
"tempFile": {
"$id": "tempFile",
"icon": "file",
Expand Down Expand Up @@ -442,38 +364,6 @@ declare type MirrorRouter = {
"builtin": true
}
},
"/pet/get": {
"POST": {
"roles": [
"root"
],
"builtin": true
}
},
"/pet/getAll": {
"POST": {
"roles": [
"root"
],
"builtin": true
}
},
"/pet/insert": {
"POST": {
"roles": [
"root"
],
"builtin": true
}
},
"/pet/upload": {
"POST": {
"roles": [
"root"
],
"builtin": true
}
},
"/user/get": {
"POST": {
"roles": [
Expand Down
1 change: 0 additions & 1 deletion api/.aeria/out/collections/index.d.mts

This file was deleted.

1 change: 0 additions & 1 deletion api/.aeria/out/collections/index.mjs

This file was deleted.

5 changes: 0 additions & 5 deletions api/.aeria/out/collections/person.d.mts

This file was deleted.

3 changes: 0 additions & 3 deletions api/.aeria/out/collections/person.mjs

This file was deleted.

6 changes: 0 additions & 6 deletions api/.aeria/out/collections/pet.d.mts

This file was deleted.

4 changes: 0 additions & 4 deletions api/.aeria/out/collections/pet.mjs

This file was deleted.

3 changes: 0 additions & 3 deletions api/.aeria/out/index.d.mts

This file was deleted.

2 changes: 0 additions & 2 deletions api/.aeria/out/index.mjs

This file was deleted.

16 changes: 0 additions & 16 deletions api/.aeria/out/package.json

This file was deleted.

26 changes: 10 additions & 16 deletions api/schemas/main.aeria
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
collection File extends aeria.file {}
collection TempFile extends aeria.tempFile {}

collection Pet {
icon "dog"
indexes {
name
collection User extends aeria.user {
form {
github_id
twitch_id
google_id
}
properties {
name str
type enum @values(["dog", "cat"])
picture File @accept(["image/*"])
}
functions {
get @expose
getAll @expose
insert @expose
upload @expose
}
presets {
crud
github_id str
twitch_id str
google_id str
}
}

25 changes: 1 addition & 24 deletions api/src/collections.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
export * from '../.aeria/out/collections/index.mjs'
export {
file, tempFile,
} from 'aeria'
import { extendCollection, user as originalUser } from 'aeria'

export const user = extendCollection(originalUser,{
description: {
form: [
'github_id',
'twitch_id',
'google_id'
],
properties: {
github_id: {
type: 'string',
},
twitch_id: {
type: 'string',
},
google_id:{
type:'string'
}
},
},
})

18 changes: 4 additions & 14 deletions api/src/routes/implementations/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ACError, type RouteContext, Result, successfulAuthentication } from 'ae
import {OAuth} from '../../oauth.js'

export const github = async(context: RouteContext)=>{

const {
GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET,
Expand All @@ -11,18 +11,8 @@ export const github = async(context: RouteContext)=>{
GITHUB_REDIRECT_URI,
} = process.env

if(
!GITHUB_CLIENT_ID
||
!GITHUB_CLIENT_SECRET
||
!GITHUB_USER_URL
||
!GITHUB_TOKEN_URL
||
!GITHUB_REDIRECT_URI
){
throw new Error('INVALID ENV FILES')
if( !GITHUB_CLIENT_ID || !GITHUB_CLIENT_SECRET || !GITHUB_USER_URL || !GITHUB_TOKEN_URL || !GITHUB_REDIRECT_URI ) {
throw new Error('missing env variables')
}

const gitTempToken = await OAuth.exchangeCodeForAccessToken(
Expand All @@ -46,7 +36,7 @@ export const github = async(context: RouteContext)=>{
github_id: gitTempUser.id.toString(),
},
})

if(userError){
//Check what user error returns
switch(userError.code){
Expand Down
Loading

0 comments on commit 852d03e

Please sign in to comment.