plan sdk stubs

This commit is contained in:
2024-09-19 14:37:08 +02:00
parent c77bfc8336
commit da01326777
4 changed files with 107 additions and 63 deletions

View File

@@ -12,6 +12,8 @@ import type { Room, Song } from './definitions';
import storeSDK from 'store.janishutz.com-sdk';
import bodyParser from 'body-parser';
const isFossVersion = true;
declare let __dirname: string | undefined
if ( typeof( __dirname ) === 'undefined' ) {
__dirname = path.resolve( path.dirname( '' ) );
@@ -27,30 +29,35 @@ const run = () => {
credentials: true,
origin: true
} ) );
// storeSDK.configure( JSON.parse( '' + fs.readFileSync( path.join( __dirname + '/config/store-sdk.config.testing.json' ) ) ) );
storeSDK.configure( JSON.parse( '' + fs.readFileSync( path.join( __dirname + '/config/store-sdk.config.secret.json' ) ) ) );
if ( !isFossVersion ) {
// storeSDK.configure( JSON.parse( '' + fs.readFileSync( path.join( __dirname + '/config/store-sdk.config.testing.json' ) ) ) );
storeSDK.configure( JSON.parse( '' + fs.readFileSync( path.join( __dirname + '/config/store-sdk.config.secret.json' ) ) ) );
}
const httpServer = createServer( app );
// Load id.janishutz.com SDK and allow signing in
sdk.routes( app, ( uid: string ) => {
return new Promise( ( resolve, reject ) => {
account.checkUser( uid ).then( stat => {
resolve( stat );
} ).catch( e => {
reject( e );
if ( !isFossVersion ) {
// Load id.janishutz.com SDK and allow signing in
sdk.routes( app, ( uid: string ) => {
return new Promise( ( resolve, reject ) => {
account.checkUser( uid ).then( stat => {
resolve( stat );
} ).catch( e => {
reject( e );
} );
} );
} );
},
( uid: string, email: string, username: string ) => {
return new Promise( ( resolve, reject ) => {
account.createUser( uid, username, email ).then( stat => {
resolve( stat );
} ).catch( e => {
reject( e );
},
( uid: string, email: string, username: string ) => {
return new Promise( ( resolve, reject ) => {
account.createUser( uid, username, email ).then( stat => {
resolve( stat );
} ).catch( e => {
reject( e );
} );
} );
} );
}, sdkConfig );
}, sdkConfig );
}
// Websocket for events
interface SocketData {

View File

@@ -0,0 +1,11 @@
import express from 'express';
// TODO: Use also express-session to make it work with getSessionID and session referencing
const checkAuth = ( request: express.Request ) => {
return true;
}
export default {
checkAuth
}

View File

@@ -0,0 +1,11 @@
const getSubscriptions = ( uid: string ) => {
return [ {
'id': 'com.janishutz.MusicPlayer.subscription',
'expires': new Date().getTime() + 200000,
'status': true
} ]
}
export default {
getSubscriptions
}