Skip to content

scott-walker/node-static-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Статический NodeJS сервер

Build Status NPM Package Scottweb

Простой статический сервер написанный на NodeJS без использования сторонних библиотек

Пример использования

const { StaticServer } = require("@scottwalker/node-static-server")

// Инициализировать сервер
const server = new StaticServer({
  protocol: "http",
  host: "localhost",
  port: 3030,
  rootDir: "./public",
  indexFile: "index.html",
  notFoundFile: "notFound.html",
  mimeTypes: {
    "custom": "text/custom"
  }
})

// Слушать событие запуска
server.on("start", ({ message }) => console.log(message))

// Запустить сервер
server.start()

Конфигурация

protocol - протокол соединения
host - хост соединения
port - порт соединения
rootDir - корневая директория для статических файлов
indexFile - индексный файл
notFoundFile - файл показываемый в случае ошибки 404
mimeTypes - карта расширений и их MIME-типов

About

🟡📦🗃️ Node Static Server — Simple static NodeJS Server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors