You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
following #795
Glee is a great tool for API-first development, but it hasn't gained much traction. I believe the issues are mostly::
Shallow learning curve: due to limiting the user to use rigid file structure for operations, lifecycles, and authentication.
Difficulty in managing a global state: Each operation/lifecycle function must be in its file, it makes having a centralized state harder.
Can only be used in the node environment
Proposed Solution:
Get Rid of File-based routing: To be honest, I don't see why we are forcing users to have functions and lifecycles folders and follow a rigid file-based operation handlers structure.
Frameworks like Next.js use folders since they have a good excuse for it, (ie, file-based routing) but Glee is more like Express.js, at the end user only needs to pass operation handlers and we take care of the rest.
Adapters should be separate packages: By having adapters as separate packages their development can be more streamlined, and they can be maintained by their respective contributors. plus user can write their adapter and plug it in.
It will help us run glee in the browser as well as the node environment, given the provided adapter supports it.
How should it look like:
an example demonstrating how the glee interface should look like:
import{Parser}from'@asyncapi/parser';import{WSServerAdapter}from'Aasyncapi/glee-adapters-ws';import{Glee}from'@asyncapi/glee';importtype{Context,Message}from'@asyncapi/glee';//parse the asyncapi fileconstparser=newParser()constfile=awaitBun.file('asyncapi.yaml').text()const{document}=awaitparser.parse(file)if(!document)thrownewError('Invalid asyncapi file')//Initialize the Glee instance//GleeOptions will include the configuration that we do with glee.config.js and .env file.constglee=newGlee(document,{}: GleeOptions)//Add the adapterglee.use(newWSServerAdapter({}: AdapterOptions))//Add the operation handlerglee.use('hello',(message: Message,context: Context)=>{console.log('Received:',message.payload)//this is how we reply to the messagemessage.reply('world')//this is how we send a message to a specific servercontext.send('server-id','message to server-id')})//Add event listenersglee.on('connection:open',({connection, serverId})=>{// A connection has been established to one of the servers})glee.on('connection:close',({connection, serverId})=>{// A connection has been closed})glee.connect()
Adapters are required to Extend this class:
the events that they can emit are standardised.
The protocols and the environment that they can run should be specified.
import{EventEmitter}from'events'import{GleeError}from'../Errors'importtype{ServerInterface}from'@asyncapi/parser'import{AsyncAPIServer}from'../ServerWrapper'importtype{Message}from'../Message'importtype{WebSocketConnection}from'./ws/server'interfaceAdapterEvents{'connection:open': (connection: WebSocketConnection)=>void,'connection:close': (connection: WebSocketConnection)=>void,'server:listening': ()=>void'server:shutdown': ()=>void'error': (error: GleeError)=>void,'message': (message: Message)=>void,}interfaceAdapterEvent{connection: ConnectionserverId: string}enumEnvironment{BROWSER='browser',NODE='node'}exportclassAdapterextendsEventEmitter{protected_asyncAPIServer: AsyncAPIServeremit<UextendskeyofAdapterEvents>(event: U, ...args: Parameters<AdapterEvents[U]>): boolean{returnsuper.emit(event, ...args)}on<UextendskeyofAdapterEvents>(event: U,listener: AdapterEvents[U]): this {returnsuper.on(event,listener)}constructor(server: ServerInterface){super()this._asyncAPIServer=newAsyncAPIServer(server)}asyncconnect(): Promise<Adapter>{try{returnthis._connect()}catch(e){consterrorMessage=`Unable to establish a connect to ${this.name()}.`this.emitError(newGleeError({name: 'SERVER_SERVE_ERROR',message: errorMessage,cause: e}))}returnthis}protected_connect(): Adapter{thrownewError('Method not implemented.')}name(): string{thrownewError('Method not implemented.')}send(message: Message): void{thrownewError('Method not implemented.')}protectedemitMessage(message: Message){this.emit('message',message)}protectedemitServerListening(){this.emit('server:listening')}protectedemitServerShutdown(){this.emit('server:shutdown')}protectedemitConnectionOpen=({connection}: AdapterEvent)=>{this.emit('connection:open',connection)}protectedemitConnectionClose=({connection}: AdapterEvent)=>{this.emit('connection:close',connection)}emitError(error: GleeError){this.emit('error',error)}supportedProtocols(): string[]{thrownewError('Method not implemented.')}supportedEnvironments(): Environment[]{thrownewError('Method not implemented.')}}
Technical changes:
Convert glee to a monorepo: we can release the Adapters separately and utilities like validators can have their package.
use PNPM: it works better with mono repo.
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Context:
following #795
Glee is a great tool for API-first development, but it hasn't gained much traction. I believe the issues are mostly::
Proposed Solution:
Get Rid of File-based routing: To be honest, I don't see why we are forcing users to have
functions
andlifecycles
folders and follow a rigid file-based operation handlers structure.Frameworks like
Next.js
use folders since they have a good excuse for it, (ie, file-based routing) but Glee is more likeExpress.js
, at the end user only needs to pass operation handlers and we take care of the rest.Adapters should be separate packages: By having adapters as separate packages their development can be more streamlined, and they can be maintained by their respective contributors. plus user can write their adapter and plug it in.
It will help us run glee in the browser as well as the node environment, given the provided adapter supports it.
How should it look like:
an example demonstrating how the glee interface should look like:
Adapters are required to Extend this class:
Technical changes:
The text was updated successfully, but these errors were encountered: