Giter Site home page Giter Site logo

dannystrelok / fiber-boilerplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thomasvvugt/fiber-boilerplate

0.0 1.0 0.0 1.33 MB

A boilerplate for the Fiber web framework

License: MIT License

Go 93.55% JavaScript 5.52% Dockerfile 0.23% Shell 0.66% SCSS 0.04%

fiber-boilerplate's Introduction

Fiber Boilerplate

A boilerplate for the Fiber web framework

Configuration

Different to previous versions of this boilerplate, configurations are in a single file called .env. You can copy the .env.example and change it to your needs.

This .env file represents system environment variables on your machine. This change was made with the ease-of-use with Docker in mind.

A full version of all available configurations is located in the .env.full file. Various options can be changed depending on your needs such as Database, Fiber and Middleware settings.

Keep in mind if configurations are not set, they default to Fiber's default settings which can be found here.

Routing

Routing examples can be found within the /routes directory. Both web and API routes are split, but you can adjust this to your likings.

Views

Views are located and be edited under the /resources/views directory.

You are able change this behavior using the .env file, as well as the ability to modify the Views Engine and other templating configurations using this file or using environment variables.

Controllers

Example controllers can be found within the /app/controllers directory. You can extend or edit these to your preferences.

Database

We use GORM v2 as an ORM to provide useful features to your models. Please check out their documentation here.

Models

Models are located within the /app/models directory and are also based on the GORM v2 package.

Compiling assets

This boilerplate uses Laravel Mix as an elegant wrapper around Webpack (a bundler for javascript and friends).

In order to compile your assets, you must first add them in the webpack.mix.js file. Examples of the Laravel Mix API can be found here.

Then you must run either npm install or yarn install to install the packages required to compile your assets.

Next, run one of the following commands to compile your assets with either npm or yarn:

# Run all Mix tasks
npm run dev

# Run all Mix tasks and minify output
yarn run production
# Run all Mix tasks and watch for changes (useful when developing)
yarn run watch
# Run all Mix tasks with hot module replacement
yarn run hot

Docker

You can run your own application using the Docker example image. To build and run the Docker image, you can use the following commands.

Please note, I am using host.docker.internal to point to my Docker host machine. You are free to use Docker's internal networking to point to your desired database host.

docker build -t fiber-boilerplate .
docker run -it --rm --name fiber-boilerplate -e DB_HOST=host.docker.internal -e DB_USER=fiber -e DB_PASSWORD=secret -e DB_DATABASE=boilerplate -p 8080:8080 fiber-boilerplate

Live Reloading (Air)

Example configuration files for Air have also been included. This allows you to live reload your Go application when you change a model, view or controller which is very useful when developing your application.

To run Air, use the following commands. Also, check out Air its documentation about running the air command.

# Windows
air -c .air.windows.conf
# Linux
air -c .air.linux.conf

fiber-boilerplate's People

Contributors

thomasvvugt avatar dependabot[bot] avatar

Watchers

James Cloos avatar

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.