
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Quickly build and test powerful Express API's with built in route handling, authentication, middleware, deployment and testing so that you can focus on what is really important.

Quickly build and test powerful Express API's with built in route handling, authentication, middleware, deployment and testing so that you can focus on what is really important..
import Swiftter from 'swiftter';
const app = new Swiftter("Demo");
const logger = app.loggers.create("demo");
app.server.listen(300).then(p => {
logger.info("Hello World!");
})
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. This package has been tested on Node.js 16.0 and higher.
The quickest way to get started with express is to utilize the executable swiftter(1) to generate an application as shown below: Install the executable. The executable's major version will match Express's:
$ npm install -g swiftter-cli
Make and enter a folder:
$ mkdir swiftter-demo && cd swiftter-demo
Run the CLI to create the project
$ swiftter
Install swiftter as a dependancy
$ npm i swiftter
Before you can use some of Swiftter's fancy features, you first have to import and create an app
import Swiftter from 'swiftter';
Swiftter() has a constructor of name, being a string with the name of the app
new Swiftter("swiftter-demo");Returnsnew Swiftter
path package to parse our route path
import path from 'path';
import Swiftter from 'swiftter'; // import `swiftter`
import path from 'path'; // Import `path`
const app = new Swiftter("swiftter-demo"); // Create an instance of Swiftter
Before we can use Swiftter, we need to initialize the express server ? == not required
Create an InitializeOptions variable
routes?: (path.ParsedPath) Folder location of your dynamic route filesmiddleware?: (() => (req, res, next))[] Any extra middleware you want to includeauthentication?: Authentication[] Authentication classes you want to use (see below)express
session: (false | SessionOptions?) Set to false to disable
secret: (string) A secret to use for cookiesuseCors: (boolean) Use cors() in the applicationuseBodyParser: (false | BodyParserOptions?) Set to false to disable
json?: (boolean) Use bodyParser.json();urlencoded?: (false | URLEncodedOptions) Set to false to disable || Use bodyParser.urlencoded();
extended: (boolean) Use extended mode
Initialize app.server
Swiftter#server#initialize() takes an InitializeOptions argument
app.server.initialize(serverOptions)Returnsvoid
Listen on a port
Swiftter#server#listen() takes a number argument being the port
app.server.listen(3000); ReturnsPromise<number>
import Swiftter from 'swiftter';
import path from 'path';
const app = new Swiftter("swiftter-demo");
const serverOptions: InitializeOptions = { // We creating an InitializeOptions variable
routes: path.parse(path.join(process.cwd(), "dist", "routes")),
middleware: [],
authentication: [],
express: {
session: {
secret: "SECRET :)"
},
useCors: false,
useBodyParser: false
}
}
app.server.initialize(serverOptions); // We are initializing the app with the above options
await app.server.listen(3000); // We are listening on port 3000
We can create loggers to log to the output in a fancy way
Swiftter#loggers#create() takes a string argument being the logger name
app.loggers.create("Main")ReturnsLogger
Swiftter#loggers#cache is a Map<string (name), Logger> of all the fetched/registered loggersSwiftter#loggers#get() we can fetch a logger we have already created, instead of exporting it.
app.loggers.cache.get("Main")ReturnsLogger
Logger can take a string, string[] or MessageGroup argument. These methods include;
#info()Returnsvoid#warn()Returnsvoid#error()Returnsvoid#success()Returnsvoid#debug()Only logs ifprocess.env.NODE_ENV === "development"Returnsvoid
import Swiftter from 'swiftter';
import path from 'path';
const app = new Swiftter("swiftter-demo");
const logger = app.loggers.create("Main"); // We create a logger
const serverOptions: InitializeOptions = {
routes: path.parse(path.join(process.cwd(), "dist", "routes")),
middleware: [],
authentication: [],
express: {
session: {
secret: "SECRET :)"
},
useCors: false,
useBodyParser: false
}
}
app.server.initialize(serverOptions);
app.server.listen(3000).then(p => { // We are now using .then() to collect the port
logger.success([`Listening on port:`, p]); // And logging it out using Logger#success()
});
Using the built in dynamic route features, we can simply create files in a directory to create advanced routes
InitializeOptions#routes directory and create an index.ts/ route{ Route } from swiftterimport { Route } from 'swiftter'const route: Route = {}method property, being (get|post|patch|delete|put) to set the method of the routemethod: "get"handler property, being a (req, res) => void function to handle the routehandler(req, res) => {}path property to set the web path of the route, this will disable dynamic routing for the filepath: "/hello"export default the route objectexport default route; With route being the variable nameimport { Route } from 'swiftter'; // We are importing the route type
const route: Route = {
method: 'get', /* The method of the route, can be "get", "post", "put", "patch", or "delete" */
// path: '/optional', /* The "path" paramater is optional, it defaults to using dynamic routing */
handler: (req, res) => { /* A handler function, taking "req" and "res" as arguments */
res.send(`Hello World`)
},
};
export default route; /* Export the route object */
Swiftter has built in authentication, to make it easy to encorperate simple or even complex authentication stratergies
{ Scope, DiscordAuthentication } from 'swiftter'
import { Scope, DiscordAuthentication } from 'swiftter';
DiscordAuthenticationOptions variable
clientID: (string) Your discord application's client idclientSecret: (string) Your discord application's client secretcallbackURL: (string) A callback url you added to your discord application's oAuth settings. Make sure it calls back to this appscopes: (Scope[]) A list of scopes from thescopeenumurls
successUrl: (string) Url to redirect to after successful login. Defaults to/callback: (string) The path to yourcallbackURL. Defaults to/auth/callback/discordauthorization: (string) Url a user needs to go to to authenticate. Defaults to/auth/discordfailureRedirect: (string) Url a user is redirected to if the redirect fails. Defaults to/storage
methods: (string)
FAQs
Quickly build and test powerful Express API's with built in route handling, authentication, middleware, deployment and testing so that you can focus on what is really important.
We found that swiftter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.