Giter Site home page Giter Site logo

niclashaderer / luftschloss Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 2.63 MB

Dependencyless pure typescript webserver with openapi generation

License: MIT License

Shell 0.12% TypeScript 99.21% JavaScript 0.32% Dockerfile 0.34%
http node server typescript

luftschloss's Introduction

Luftschloss

Luftschloss is a simple, lightweight and dependency-free webserver in Node.js.

Getting started

# (If you don't have yarn installed install it with `npm install -g yarn`)
# Install dependencies used for building the project
yarn install


# Build all projects and apps
npx nx run-many -t build --all

Structure of the repository

All packages are located in the packages folder. The apps folder contains all applications that are built on top of the packages and can be viewed as a showcase of the packages.

Packages

  1. @luftschloss/client: A http client for Node.js
  2. @luftschloss/common: The core package containing common functionality used by most other packages.
  3. @luftschloss/mocking: Automatically mock your api calls.
  4. @luftschloss/openapi: An openapi extension for the @luftschloss/server package. Just write your code and the openapi spec will be generated automatically.
  5. @luftschloss/openapi-schema: The schema generation logic for the @luftschloss/openapi package.
  6. @luftschloss/proxy: A proxy server for the @luftschloss/server package built on top of the @luftschloss/client package.
  7. @luftschloss/server: The luftschloss http server
  8. @luftschloss/static: Static file extensions for the @luftschloss/server package.
  9. @luftschloss/testing: Testing utilities for the @luftschloss/server package. Use this to test your server without ever having to start it.
  10. @luftschloss/validation: A custom validation library which can be used on the client and server side. It is used by the @luftschloss/openapi package.

Demonstration applications

โš ๏ธ

  1. make sure that you have set Thunder-client: Save To Workspace to true in your vscode settings
  2. make sure that you disable Thunder-client: Follow Redirect in the thunderclient settings
  3. make sure you delete the shortener.db file and the users.db file before starting the application to make sure
 that the database is empty

url-shortener

The application in apps/url-shortener is a simple url shortener application. It uses the @luftschloss/openapi package in combination with the @luftschloss/server to automatically generate an openapi spec. The @luftschloss/client package is used to verify that the urls which should be shortened actually exist and return a successful status code.

Be aware of the fact that without a JWT you will not be able to shorten urls. Obtain an JWT by making a request to the authentication service. The authentication service has to be running for the url-shortener to work.

# Start the application
npx nx serve url-shortener

# Open the openapi spec (choose one of the following)
open http://127.0.0.1:3200/docs/swagger
open http://127.0.0.1:3200/docs/stoplight
open http://127.0.0.1:3200/docs/redoc

authentication

The application in apps/authentication is a simple authentication application. It uses the @luftschloss/openapi and @luftschloss/server packages to automatically generate an openapi spec.

# Start the application
npx nx serve authentication

# Open the openapi spec (choose one of the following)
open http://127.0.0.1:3300/docs/swagger
open http://127.0.0.1:3300/docs/stoplight
open http://127.0.0.1:3300/docs/redoc

# Open vs-code and open the thunderclient extension
# 1. Run the *authentication* collection before the *url-redirect* collection
code apps/authentication

Build the docker images

# Build the docker images
nx container url-shortener
nx container authentication
# Tag the docker images
docker tag luftschloss/url-shortener:main andfaxle/url-shortener:latest
docker tag luftschloss/authentication:main andfaxle/authentication:latest
# Push the docker images to docker hub to repo andfaxle/wscbs
docker push andfaxle/url-shortener:latest
docker push andfaxle/authentication:latest
# Start the docker images
docker run -p 3200:3200 luftschloss/url-shortener:main
docker run -p 3300:3300 luftschloss/authentication:main

# Add a new docker build target to an application
nx g @nx-tools/nx-container:init <app-name>

luftschloss's People

Contributors

gropaul avatar niclashaderer avatar selfoluap avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

luftschloss's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.