Start api
This commit is contained in:
parent
bc4a4224de
commit
662ba0aa3d
12
.idea/dataSources.xml
Normal file
12
.idea/dataSources.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="mathy@localhost" uuid="d7b1325c-41d2-4d9e-9728-88db6eeedda2">
|
||||||
|
<driver-ref>postgresql</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:postgresql://localhost:5432/mathy</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,5 +1,5 @@
|
|||||||
import { env } from '@extollo/lib'
|
import { env } from '@extollo/lib'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: env('APP_NAME', 'Extollo'),
|
name: env('APP_NAME', 'Mathy'),
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,8 @@
|
|||||||
import {AuthenticationConfig, CoreIDLoginProvider, OAuth2LoginProviderConfig, ORMUserRepository, env} from '@extollo/lib'
|
import {AuthenticationConfig, ORMUserRepository} from '@extollo/lib'
|
||||||
|
|
||||||
const authConfig: AuthenticationConfig = {
|
const authConfig: AuthenticationConfig = {
|
||||||
storage: ORMUserRepository,
|
storage: ORMUserRepository,
|
||||||
providers: {
|
providers: {},
|
||||||
coreid: {
|
|
||||||
driver: CoreIDLoginProvider,
|
|
||||||
config: {
|
|
||||||
default: true,
|
|
||||||
displayName: 'Starship CoreID',
|
|
||||||
clientId: env('COREID_CLIENT_ID'),
|
|
||||||
clientSecret: env('COREID_CLIENT_SECRET'),
|
|
||||||
loginUrl: env('COREID_BASE', '') + '/auth/service/oauth2/authorize?client_id=%c&redirect_uri=%r',
|
|
||||||
tokenUrl: env('COREID_BASE', '') + '/auth/service/oauth2/redeem',
|
|
||||||
userUrl: env('COREID_BASE', '') + '/api/v1/auth/users/me',
|
|
||||||
} as OAuth2LoginProviderConfig,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default authConfig
|
export default authConfig
|
||||||
|
@ -6,9 +6,9 @@ import {
|
|||||||
LocalFilesystemConfig,
|
LocalFilesystemConfig,
|
||||||
RedisCache,
|
RedisCache,
|
||||||
CacheQueue,
|
CacheQueue,
|
||||||
BusConnectorConfig, QueueConfig, SyncQueue
|
BusConnectorConfig,
|
||||||
|
QueueConfig,
|
||||||
} from "@extollo/lib"
|
} from "@extollo/lib"
|
||||||
import {LogRequest} from "../http/middlewares/LogRequest.middleware";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
debug: env('DEBUG_MODE', false),
|
debug: env('DEBUG_MODE', false),
|
||||||
@ -60,7 +60,7 @@ export default {
|
|||||||
|
|
||||||
middleware: {
|
middleware: {
|
||||||
global: {
|
global: {
|
||||||
pre: [LogRequest],
|
pre: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
32
src/app/http/controllers/api/Login.controller.ts
Normal file
32
src/app/http/controllers/api/Login.controller.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import {Controller, view, Inject, Injectable, SecurityContext, api} from '@extollo/lib'
|
||||||
|
import {User} from '../../../models/User.model'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Login Controller
|
||||||
|
* ------------------------------------
|
||||||
|
* API routes related to logging users into the application.
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
export class Login extends Controller {
|
||||||
|
@Inject()
|
||||||
|
protected readonly security!: SecurityContext
|
||||||
|
|
||||||
|
public status() {
|
||||||
|
return api.one({
|
||||||
|
hasUser: this.security.hasUser(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public user() {
|
||||||
|
const user = this.security.getUser()
|
||||||
|
if ( !user ) {
|
||||||
|
return api.error('There is no user authenticated.')
|
||||||
|
}
|
||||||
|
|
||||||
|
return api.one(user)
|
||||||
|
}
|
||||||
|
|
||||||
|
public async callbackFromAuth0() {
|
||||||
|
return api.error('Implement me!')
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,7 @@ export class Home extends Controller {
|
|||||||
|
|
||||||
const valid = new Promise<UserLogin>(() => {})
|
const valid = new Promise<UserLogin>(() => {})
|
||||||
|
|
||||||
return view('@extollo:welcome', {
|
return view('welcome', {
|
||||||
app_visits: this.session.get('app_visits'),
|
app_visits: this.session.get('app_visits'),
|
||||||
locale: this.locale.helper(),
|
locale: this.locale.helper(),
|
||||||
})
|
})
|
||||||
|
@ -1,13 +1,26 @@
|
|||||||
import {Route, SessionAuthMiddleware, AuthRequiredMiddleware} from '@extollo/lib'
|
import {Route, SessionAuthMiddleware} from '@extollo/lib'
|
||||||
import {Home} from '../controllers/main/Home.controller'
|
import {Home} from '../controllers/main/Home.controller'
|
||||||
|
import {Login} from '../controllers/api/Login.controller'
|
||||||
|
|
||||||
Route.group('/', () => {
|
Route.group('/', () => {
|
||||||
Route.get('/')
|
Route.get('/')
|
||||||
.calls<Home>(Home, home => home.welcome)
|
.calls<Home>(Home, home => home.welcome)
|
||||||
})
|
|
||||||
|
|
||||||
Route.group('', () => {
|
Route.group('/api', () => {
|
||||||
Route.get('/dash')
|
Route.get('/')
|
||||||
.pre(AuthRequiredMiddleware)
|
.handledBy(() => ({
|
||||||
.calls<Home>(Home, home => home.welcome)
|
success: true,
|
||||||
|
}))
|
||||||
|
|
||||||
|
Route.group('/login', () => {
|
||||||
|
Route.get('/status')
|
||||||
|
.calls<Login>(Login, login => login.status)
|
||||||
|
|
||||||
|
Route.get('/user')
|
||||||
|
.calls<Login>(Login, login => login.user)
|
||||||
|
|
||||||
|
Route.post('/user')
|
||||||
|
.calls<Login>(Login, login => login.callbackFromAuth0)
|
||||||
|
})
|
||||||
|
})
|
||||||
}).pre(SessionAuthMiddleware)
|
}).pre(SessionAuthMiddleware)
|
||||||
|
Loading…
Reference in New Issue
Block a user