79 lines
1.5 KiB
Markdown
79 lines
1.5 KiB
Markdown
# Twtkpr
|
|
|
|
An [ExpressJS](https://expressjs.com/) router for serving, sharing, and updating a
|
|
[`twtxt.txt` file](https://twtxt.dev/).
|
|
|
|
> [!WARNING]
|
|
> **STILL IN ALPHA**: Although this is a fully-functional plugin which is actively deployed to at least one site (my
|
|
> own), it currently lacks documentation, examples, tests, installation flexibility, or polish (and still has a couple
|
|
> of bugs that need to be fixed).
|
|
> _USE AT YOUR OWN RISK_
|
|
|
|
### Features
|
|
|
|
- Uses JWT (with refresh) for security.
|
|
- Allows for adding new twts and directly editing a `twtxt.txt` file from within a browser.
|
|
- Includes a ull-featured GET API for your `twtxt.txt` file backed by an in-memory cache.
|
|
- Supports optional drag-and-drop file upload handling with automatic linking.
|
|
|
|
## Installing
|
|
|
|
Add package:
|
|
|
|
```sh
|
|
yarn add express-twtkpr
|
|
```
|
|
|
|
Generate hash:
|
|
|
|
```sh
|
|
yarn run get:hash
|
|
```
|
|
|
|
Create username and password:
|
|
|
|
```sh
|
|
yarn run set:user
|
|
```
|
|
|
|
## Using
|
|
|
|
Use it in an express application:
|
|
|
|
```
|
|
import express, { Request, Response } from "express";
|
|
|
|
import twtkpr from "express-twtkpr";
|
|
|
|
// import other middleware
|
|
|
|
const app = express();
|
|
|
|
// add other middleware
|
|
|
|
app.use(
|
|
"/",
|
|
twtkpr(
|
|
{
|
|
// config options
|
|
},
|
|
),
|
|
);
|
|
|
|
// add error handler
|
|
|
|
export default app;
|
|
|
|
```
|
|
|
|
Starting with v0.9.0, extra features (like files uploading) were moved to the [express-twtkpr-core-plugins](https://www.npmjs.com/package/express-twtkpr-core-plugins) package.
|
|
|
|
More to come!
|
|
|
|
---
|
|
|
|
## License
|
|
|
|
Copyright (c) 2026 Eric Woodward, released under the
|
|
[MIT License](https://www.itsericwoodward.com/licenses/mit/).
|