Alpine, Tailwind, Deno, SQLite My Local Service 4-Pack

Original link: https://limboy.me/posts/local-services-tools/

Sometimes you want to write some local services to meet your specific needs. This local service needs to support GUI and can read and write local files. If you write a command line tool, there will be certain limitations in interaction and display. Full featured solutions like Next.js / Electron / Tauri are again too heavy. Don’t want to introduce compilation, don’t want to see node_modules .

In this way, a front-end page combined with a local back-end service is more appropriate. For front-end pages, if you choose React or Vue , it is inevitable to introduce a whole set of compilation tools, as well as node_modules . Using jQuery is too Old School. Alpine is just right, similar to Vue in usage, but lighter and does not require compilation. After CSS uses Tailwind , it is difficult to go back. For convenience, we directly use Tailwind’s CDN file.

 < head >  < meta name = "viewport" content = "width=device-width, initial-scale=1.0" />  < script defer src= "https://unpkg.com/[email protected]/dist/cdn.min.js" ></ script >  < link    href = "https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css"    rel = "stylesheet"  /> </ head >

For back-end services, if you use node , you need to use package management tools such as npm, and there will be node_modules . If you use python , you have to find a suitable one among the many package management tools, and you have to adapt to its usage posture, and maybe combine it with pyenv , which is too complicated for a simple local service. And deno can just solve these problems: built-in package management function, no need for additional package.json or similar package declaration files; native support for JavaScript and TypeScript; comes with a lot of out-of-the-box functions (batteries-included); The surrounding ecology is also OK.

For the database, SQLite is more suitable, powerful, solid enough, single file, no need to open additional processes.

If you want to write a local password management tool, you only need 3 files:

 - LocalPass.html - LocalPass.js - LocalPass.db

In LocalPass.js , if you want to import the tripartite Lib, just:

 import {  Application ,  Router ,  helpers , } from 'https://deno.land/x/[email protected]/mod.ts' ; import * as sqlite from 'https://deno.land/x/[email protected]/mod.ts' ;

In development mode, you can use deno run -A --watch LocalPass.js , so that as long as LocalPass.js file changes, it will automatically restart. For a simple service, the development efficiency is quite high, and maintenance is also very convenient. If it is open to other people, as long as the other party has installed deno , one command can run directly.

Here is a demo of the project :

If you know some front-ends and want to write a local service (such as writing a more friendly interface for the command line tool youtube-dl ), you can try this combination, which is quite convenient.

This article is reprinted from: https://limboy.me/posts/local-services-tools/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment