Urgent.News

What's breaking now, across thousands of outlets.

Tech

I Missed @Service in Node.js, So I Built It with Express

Let the browser console create the files At first, the browser console was only a debugging tool. I wrote the same create, read, update, and delete code several times. The console already knew about controllers, services, tables, and SQL query names. So I added code generation. The basic flow is simple: SQL → New SQL file: choose a table and create named queries. Service → New service: connect…

At first, the browser console was merely a debugging tool. The author found themselves repeating the same create, read, update, and delete code multiple times. To streamline the process, they introduced code generation. The process starts with SQL, where the user selects a table and creates named queries. Then, a service is generated, with its methods linked to the queries.

Lastly, a controller is created, connecting the service to the routes. Before generating the controller file, the user can view all routes and their connection to service methods and SQL queries. Upon saving the controller, the route becomes active without needing to restart the backend. Although the console is not mandatory, it remains a useful tool for creating files in an editor and placing them in the respective workspaces.

After creating a controller, the API can be tested immediately using the built-in API tester. The Request Trace screen provides detailed information about each step of a request, including the route, controller, service method, SQL query, row count, status, and time taken. This trace helps identify the source of any issues or slow requests.

The console also records request IDs and user activity, which is crucial in hospital software for tracking data access and subsequent actions. The Screen Designer allows the creation of a basic data screen for creating, viewing, editing, and deleting records, with export options for a Vue 3 project. The exported project is a normal source code, enabling seamless integration into a team's existing workflow.

The system can function offline, with all user-interface files stored and served locally. On Windows, the backend can run as a Windows service, and an Electron desktop app can serve as a viewer. The project, along with the framework, browser console, API tester, request tracing, and Screen Designer, is available in the public GitHub repository under the Apache License 2.0.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Saturday 26 September →