Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lortschi/vm-meteor-react-boilerplate

vm-meteor-react-boilerplate
https://github.com/lortschi/vm-meteor-react-boilerplate

admin-area authorization boilerplate eslint i18n languag-switche meteor meteor-react meteorjs nodejs reactjs sass scss semantic-ui starter usermanagement

Last synced: about 2 months ago
JSON representation

vm-meteor-react-boilerplate

Awesome Lists containing this project

README

        

Meteor React Semantic-UI Progressive WebApp Boilerplate is a sample Meteor 1.9 application that illustrates:

* A standard directory layout using 'imports/' as recommended in the [Meteor Guide](https://guide.meteor.com/structure.html)
* [Semantic UI React](https://react.semantic-ui.com/) for user interface.
* [SCSS Preprocessor](https://github.com/Meteor-Community-Packages/meteor-scss) based on fourseven:scss.
* [Meteor-Universe-i18n ](https://github.com/vazco/meteor-universe-i18n) internationalization language package.
* [Uniforms](https://uniforms.tools/) for form development.
* [alanning:roles](https://github.com/alanning/meteor-roles) to implement a special "Admin" user.
* Authorization, authentication, and registration using built-in Meteor packages.
* Initialization of users and data from a settings file.
* Alerts regarding success or failure of DB updates using [Sweet Alert](https://sweetalert.js.org/).
* Quality assurance using [ESLint](http://eslint.org) with packages to partially enforce the [Meteor Coding Standards](https://guide.meteor.com/code-style.html) and the [AirBnB Javascript Style Guide](https://github.com/airbnb/javascript).
* Responsive mobile ready.

The goal of this template is to help you get quickly started doing Meteor development by providing a reasonable directory structure for development and deployment, a set of common extensions to the core framework, and boilerplate code to implement basic page display, navigation, forms, roles, and collection manipulation.

## Installation

Install first the Meteor Framework, [install Meteor](https://www.meteor.com/install).

Cd into the app/ directory of your local copy of the repo, and install third party libraries with:

```
$ meteor npm install
```

## Running the system

Once the libraries are installed, you can run the application by invoking the "start" script in the [package.json file](https://github.com/lortschi/vm-meteor-react-boilerplate/blob/master/app/package.json):

```
$ meteor npm run start
```

The first time you run the app, it will create some default users and data. Here is the output:

```
meteor npm run start

> vm-meteor-react-boilerplate$

[[[[[ ~/github/lortschi/vm-meteor-react-boilerplate/app ]]]]]

=> Started proxy.
=> Started MongoDB.
I20180227-13:33:02.716(-10)? Creating the default user(s)
I20180227-13:33:02.742(-10)? Creating user [email protected].
I20180227-13:33:02.743(-10)? Creating user [email protected].
I20180227-13:33:02.743(-10)? Creating default data.
I20180227-13:33:02.743(-10)? Adding: Basket ([email protected])
I20180227-13:33:02.743(-10)? Adding: Bicycle ([email protected])
I20180227-13:33:02.743(-10)? Adding: Banana ([email protected])
I20180227-13:33:02.744(-10)? Adding: Boogie Board ([email protected])
=> Started your app.

=> App running at: http://localhost:3000/
```

### Note regarding "bcrypt warning":

You will also get the following message when you run this application:

```
Note: you are using a pure-JavaScript implementation of bcrypt.
While this implementation will work correctly, it is known to be
approximately three times slower than the native implementation.
In order to use the native implementation instead, run

meteor npm install --save bcrypt

in the root directory of your application.
```

On some operating systems (particularly Windows), installing bcrypt is much more difficult than implied by the above message. Bcrypt is only used in Meteor for password checking, so the performance implications are negligible until your site has very high traffic. You can safely ignore this warning without any problems during initial stages of development.

### Note regarding "MongoError: not master and slaveOk=false":

Intermittently, you may see the following error message in the console when the system starts up:

```
MongoError: not master and slaveOk=false
at queryCallback (/Users/lortschi/.meteor/packages/npm-mongo/.3.1.1.1mmptof.qcqo++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb-core/lib/cursor.js:248:25)
at /Users/lortschi/.meteor/packages/npm-mongo/.3.1.1.1mmptof.qcqo++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb-core/lib/connection/pool.js:532:18
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
```

While irritating, this message appears to be harmless and [possibly related to a race condition between the development instance of Mongo and Meteor](https://github.com/meteor/meteor/issues/9026#issuecomment-330850366). By harmless, I mean that in most cases, the console goes on to display `App running at: http://localhost:3000/` and no problems occur during run time.

### Viewing the running app

If all goes well, the template application will appear at [http://localhost:3000](http://localhost:3000). You can login using the credentials in [settings.development.json](https://github.com/lortschi/vm-meteor-react-boilerplate/blob/master/config/settings.development.json), or else register a new account.

### ESLint

You can verify that the code obeys our coding standards by running ESLint over the code in the imports/ directory with:

```
meteor npm run lint
```

### Directory structure

The top-level directory structure is:

```
app/ # holds the Meteor application sources
config/ # holds configuration files, such as settings.development.json
doc/ # holds developer documentation, user guides, etc.
```

This structure separates documentation files (such as screenshots) and configuration files (such as the settings files) from the actual Meteor application.

The app/ directory has this structure:

```
client/
main.html # The boilerplate HTML with a "root" div to be manipulated by React.
main.js # import startup files.

imports/
api/ # Define collections
stuff/ # The Stuff collection definition
startup/ # Define code to run when system starts up (client-only, server-only, both)
client/
server/
ui/
layouts/ # Contains top-level layout ( component).
pages/ # Contains components for each page.
components/ # Contains page elements, some of which could appear on multiple pages.

node_modules/ # managed by npm

public/ # static assets (like images) can go here.

server/
main.js # import the server-side js files.
```

### Import conventions

This system adheres to the Meteor guideline of putting all application code in the imports/ directory, and using client/main.js and server/main.js to import the code appropriate for the client and server in an appropriate order.

### Application functionality

The application implements a simple CRUD application for managing "Stuff", which is a Mongo Collection consisting of a name (String), a quantity (Number), and a condition (one of 'excellent', 'good', 'fair', or 'poor').

By default, each user only sees the Stuff that they have created. However, the settings file enables you to define default accounts. If you define a user with the role "admin", then that user gets access to a special page which lists all the Stuff defined by all users.

### Component UI Styles and Theming

The application uses the [React implementation of Semantic UI](http://react.semantic-ui.com/) and theming.

### SCSS / CSS

The style.scss allows to overwrite the default theme styles or create new ones.

### Routing

For display and navigation among its four pages, the application uses [React Router](https://reacttraining.com/react-router/).

Routing is defined in [imports/ui/layouts/App.jsx](https://github.com/lortschi/vm-meteor-react-boilerplate/blob/master/app/imports/ui/layouts/App.jsx).

### Authentication

For authentication, the application uses the Meteor accounts package.

When the application is run for the first time, a settings file (such as [config/settings.development.json](https://github.com/lortschi/vm-meteor-react-boilerplate/blob/master/config/settings.development.json)) should be passed to Meteor. That will lead to a default account being created through the code in [imports/startup/server/accounts.js](https://github.com/lortschi/vm-meteor-react-boilerplate/blob/master/app/imports/startup/server/accounts.js).

The application allows users to register and create new accounts at any time.

### Authorization

Only logged in users can manipulate Stuff documents (but any registered user can manipulate any Stuff document, even if they weren't the user that created it.)

### Configuration

The [config](https://github.com/lortschi/vm-meteor-react-boilerplate/tree/master/config) directory is intended to hold settings files. The repository contains one file: [config/settings.development.json](https://github.com/lortschi/vm-meteor-react-boilerplate/blob/master/config/settings.development.json).

The [.gitignore](https://github.com/lortschi/vm-meteor-react-boilerplate/blob/master/.gitignore) file prevents a file named settings.production.json from being committed to the repository. So, if you are deploying the application, you can put settings in a file named settings.production.json and it will not be committed.

### Quality Assurance

#### ESLint

The application includes a [.eslintrc](https://github.com/lortschi/vm-meteor-react-boilerplate/blob/master/app/.eslintrc) file to define the coding style adhered to in this application. You can invoke ESLint from the command line as follows:

```
[~/vm-meteor-react-boilerplate/app]-> meteor npm run lint

> vm-meteor-react-boilerplate@ lint /Users/lortschi/meteor-application-template-react/app
> eslint --quiet ./imports
```

ESLint should run without generating any errors.

### Screencasts of the GUI
!['home'](app/public/themes/default/assets/images/home_screenshot.png)
!['home-lang'](app/public/themes/default/assets/images/home-lang_screenshot.png)
!['login'](app/public/themes/default/assets/images/login_screenshot.png)
!['mobile'](app/public/themes/default/assets/images/mobile-login_screenshot.png)