23.1.2 • Published 2 years ago

server-emulator v23.1.2

Weekly downloads
52
License
GPL-3.0
Repository
github
Last release
2 years ago

A simple storage app that emulates the file system

Supported NodeJS

  • >= 12.x

Supported Systems:

  • Windows
  • Linux

Codacy Badge

Use:

  • You can use either server or server-emulator
server-emulator daemon # starts a daemon process
server daemon # starts a daemon process

server-emulator kill # kills the daemon process
server kill # kills the daemon process

server-emulator # starts the process without daemonizing 
server-emulator start # starts the process without daemonizing 

server # starts the process without daemonizing 
server start # starts the process without daemonizing 

server-emulator set APP_PORT 8000 # changes the app port
server set APP_PORT 8000 # changes the app port

sever-emulator set ENABLE_SECURITY 1 # enables the user management
sever set ENABLE_SECURITY 1 # enables the user management
  • List of commands:
Commands:
server-emulator ---> starts the server
server-emulator start ---> starts the server
server-emulator daemon ---> starts the server in a detached deamon mode, returns the PID. If a daemon is running, will output the daemon pid
server-emulator kill  ---> kills the daemon
server-emulator getProjectDir ---> returns the absolute path to the project
server-emulator getEnvPath ---> returns the absolute path to the .env file
server-emulator terminal ---> installs terminal dependencies ( currently not working )
server-emulator set ${ENV_KEY} ${ENV_VALUE} ---> Changes .env file values or adds new ones.
server-emulator get ---> Gets all the .env variables
server-emulator resetEnv ---> Resets the .env file to the defaults.
server-emulator setEnv ---> Sets a new location for the .env file and resets it
server-emulator deletePid ---> Deletes the PID file

Enabling the terminal

Windows

npm install --global windows-build-tools
server-emulator set ENABLE_TERMINAL 1
server-emulator terminal

Linux

server-emulator set ENABLE_TERMINAL 1
server-emulator terminal

Terminal Dependencies

Port Forwarding

  • You can enable port forwarding on your router to point to the local machine running the server emulator on a given port
  • This way you can access the server using your public IP
  • Search "Router Port Forwarding" for more information

Modifications

  • You can modify the .env file to your needs.
  • APP_PORT will be which port the app is attached to
  • ENABLE_SECURITY - whether to secure the app 1 or 0
  • ADMIN_USERNAME and ADMIN_PASSWORD - in case of enabled security what are the password and the username
  • REQUEST_TIMEOUT - How much to keep requests active for in milliseconds
  • UPLOADS_DIR - where to put the temporary upload files
  • ENABLE_TERMINAL - 1 or 0 whether the terminal should be enabled ( CURRENTLY NOT WORKING )
  • ENABLE_SECURITY_HEADERS - 1 or 0 whether the security headers should be enabled or not ( hsts, Expect-CT, CSP, Content Type Options )
  • DEBUG - Whether to write logs on a debug level 1 or 0
  • USERS_DIR - Where the users should be stored. If empty then the os.tmpDir will be used, if === 'LOCAL_DIR' then the project root will be used
  • TERMINAL_TO_SPAWN - the name of the terminal process to spawn ( for example: In windows if you have git bash you can spawn bash.exe )
  • SSL_KEY_PATH - The ABSOLUTE path to the SSL key
  • SSL_CERT_PATH - The ABSOLUTE path to the SSL certificate
  • Others should probably not be touched

Enabling SSL

  • Generate a certificate and point the SSL_KEY_PATH and SSL_CERT_PATH to their locations
  • Set the APP_PORT to 443

Changing env file location

  • By default the env file that the server will use will be located in the OS' temp folder.
  • If you wish to change it you can do it by: server-emulator setEnv . ( this will change it to the current folder)
  • This will reset any env variables you may have set before, so back those up
  • It is a good idea to put this in the project directory, as this will prevent it from modified by anyone who is not a Super user

Adding users

  • If you want to add users go to the users page from the sidebar and click on the Add Users button
  • You will be asked to fill in the new user's data
  • Route will be the path from which the user can access the FS
  • When adding a user the user will persist after 5 seconds so don't stop the server
  • User's data is stored to the OS tmp directory by default and can be changed using the USERS_DIR variable ( either LOCAL_DIR or empty )

Permissions:

  • Only superusers can use the terminal, add/ view/ modify other users ( and self ). Only superusers can access the project folder and the OS tmp directory.
  • Nobody can delete or change the permissions of the root user.
  • Nobody can do any operations on the PROJECT_ROOT as well as many operations including the folder structure where the project is
  • When adding a user a set of permissions will be asked for. Those permissions are forbidding. Whatever you type in there, the users WON'T be able to access.
  • You may leave the method empty which will mean ANY method or pass in an Array

Notes

  • You may need to delete the cache file if you do changes to the environment ( like enabling security )
  • If a state arises where there is no root user, one will be created automatically ( with the username and password in the .env file )
  • It is a good idea to change the password ( via the gui and in the .env ) after you've started the server

Known Bugs:

  • Some functionality is broken on virtual machines...
  • Cannot detect if you are moving a folder inside itself, so you can't do this:
      /
          /folder
          /folder2
          
    • copy /folder into /folder2 since I cannot distinguish whether you are trying to copy a folder into itself which will brick your disk if it happens
23.1.2

2 years ago

23.1.1

2 years ago

23.0.0

2 years ago

23.1.0

2 years ago

22.4.1

2 years ago

22.3.0

3 years ago

22.4.0

3 years ago

22.2.0

3 years ago

22.0.3

3 years ago

22.0.2

3 years ago

22.0.4

3 years ago

22.1.0

3 years ago

22.0.1

3 years ago

21.0.2

3 years ago

21.0.1

3 years ago

21.0.0

3 years ago

22.0.0

3 years ago

20.0.0

3 years ago

19.1.0

3 years ago

19.0.0

3 years ago

18.0.1

3 years ago

18.0.0

3 years ago

17.5.0

3 years ago

17.6.0

3 years ago

17.3.0

3 years ago

17.4.0

3 years ago

17.2.0

3 years ago

17.1.4

3 years ago

17.1.5

3 years ago

17.0.5

3 years ago

17.0.7

3 years ago

17.0.6

3 years ago

17.1.2

3 years ago

17.1.1

3 years ago

17.1.3

3 years ago

17.1.0

3 years ago

17.0.3

3 years ago

17.0.2

3 years ago

17.0.4

3 years ago

17.0.1

3 years ago

17.0.0

3 years ago

16.3.2

3 years ago

16.3.1

3 years ago

16.3.0

3 years ago

16.2.3

3 years ago

16.2.2

3 years ago

16.2.1

3 years ago

16.2.0

3 years ago

16.1.0

4 years ago

16.0.0

4 years ago

15.0.3

4 years ago

15.0.2

4 years ago

15.0.1

4 years ago

15.0.0

4 years ago

14.0.7

4 years ago

14.0.5

4 years ago

14.0.6

4 years ago

14.0.2

4 years ago

14.0.3

4 years ago

14.0.0

4 years ago

14.0.1

4 years ago

13.0.2

4 years ago

13.0.1

4 years ago

13.0.0

4 years ago

12.5.3

4 years ago

12.5.2

4 years ago

12.5.0

4 years ago

12.5.1

4 years ago

12.2.4

4 years ago

12.2.3

4 years ago

12.2.1

4 years ago

12.2.2

4 years ago

12.2.0

4 years ago

12.1.0

4 years ago

12.0.3

4 years ago

12.0.0

4 years ago

12.0.1

4 years ago

12.0.2

4 years ago

11.3.3

4 years ago

11.3.4

4 years ago

11.3.5

4 years ago

11.2.1

4 years ago

11.3.1

4 years ago

11.3.2

4 years ago

11.3.0

4 years ago

11.1.2

4 years ago

11.1.1

4 years ago

11.0.0

4 years ago

11.1.0

4 years ago

10.0.1

4 years ago

10.0.0

4 years ago

9.1.2

4 years ago

9.1.1

4 years ago

9.1.0

4 years ago

9.0.1

4 years ago

8.11.2

4 years ago

9.0.0

4 years ago

8.11.1

4 years ago

8.11.0

4 years ago

8.10.0

4 years ago

8.9.0

4 years ago

8.9.1

4 years ago

8.8.1

4 years ago

8.8.0

4 years ago

8.7.1

4 years ago

8.7.0

4 years ago

8.6.1

4 years ago

8.6.0

4 years ago

8.5.1

4 years ago

8.5.0

4 years ago

8.4.1

4 years ago

8.3.0

4 years ago

8.4.0

4 years ago

8.2.5

4 years ago

8.2.4

4 years ago

8.2.3

4 years ago

8.2.1

4 years ago

8.2.0

4 years ago

8.2.2

4 years ago

8.1.2

4 years ago

8.1.1

4 years ago

8.1.0

4 years ago

8.0.5

4 years ago

8.0.4

4 years ago

8.0.1

4 years ago

8.0.3

4 years ago

8.0.2

4 years ago

8.0.0

4 years ago