https://github.com/scott-walker/node-static-server
🟡📦🗃️ Node Static Server — Simple static NodeJS Server
https://github.com/scott-walker/node-static-server
nodejs npm-package static-server
Last synced: 23 days ago
JSON representation
🟡📦🗃️ Node Static Server — Simple static NodeJS Server
- Host: GitHub
- URL: https://github.com/scott-walker/node-static-server
- Owner: scott-walker
- License: apache-2.0
- Created: 2021-01-20T18:51:21.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-21T18:09:53.000Z (over 5 years ago)
- Last Synced: 2025-11-23T14:08:30.688Z (5 months ago)
- Topics: nodejs, npm-package, static-server
- Language: JavaScript
- Homepage: https://scottwalker.ru
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Статический NodeJS сервер
[](https://github.com/scottwalker87/node-static-server)
[](https://www.npmjs.com/package/@scottwalker/node-static-server)
[](http://scottweb.ru/)
Простой статический сервер написанный на NodeJS без использования сторонних библиотек
#### Пример использования
```js
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-типов
```