Giter Site home page Giter Site logo

fysikteknologsektionen / foton-gallery Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5.15 MB

Photo gallery application for Foton at the Physics Divison at Chalmers University of Technology.

Home Page: https://foton.ftek.se

License: GNU General Public License v3.0

HTML 1.96% TypeScript 96.34% SCSS 1.69%
typescript react nodejs express bootstrap oauth2 bootstrap5 javascript

foton-gallery's Introduction

foton-gallery

A photo gallery web-application for Foton (Photon) at Fysikteknologsektionen (The Physics Division) at Chalmers University of Technology.

Requirements

  • Node.js (14.x.x or later)
  • MongoDB (4.4.x or later)
  • Google OAuth 2.0 client (Read about)

Some of the dependencies use external libraries that may have to be built from source if there are no prepackaged versions available for your system. This may require additional build tools.

Installation

The project has post-install hooks to install nested dependencies. Simply install all dependencies by running

npm install

in the root directory.

Configuration

Before building or starting a dev server the project has to be configured. This is done by supplying a .env file in the root directory. There is an example configuration file, .env.example, which can be used as a template.

Google OAuth 2.0

The project uses Google OAuth 2.0 for authenticating users. For this to work you must first create a new project at the Google Cloud Console, then configure the OAuth consent screen and finally create a new OAuth 2.0 client ID (All of this can be found under the APIs & Services tab).

When configuring the OAuth consent screen the profile and email scopes must be included for the application to work. When creating the client ID Authorized JavaScript origins should be set to the top level url, i.e. https://foton.ftek.se and Authorized redirect URIs should be set to the /api/auth/google/callback subdirectory, i.e. https://foton.ftek.se/api/auth/google/callback.

In addition to any domain-restrictions imposed by the OAuth 2.0 client (i.e. if setting it to internal users only), the application uses a regular expression match to check for allowed emails. The regular expression should be set in the .env file.

Building for production

To build the project for a production environment, run

npm run build

in the root directory. This will compile all typescript and build the react project. It is important to change the NODE_ENV variable in .env to production when running the project in production since sensitive information may otherwise be exposed to clients.

Running a development environment

The project has a built in webpack dev-server (with create-react-app) and uses ts-node-dev to run a node dev-server which compiles typescript at run time. These can be started independently from the client and server directories respectively or simultaneously by running

npm run dev

in the root directory. The webpack server runs on port 3000 by default and is set to proxy requests to port 3001 (see the previous section on how to configure the project).

Generating dummy content

The project includes a script to generate dummy content for development. This can be run with ts-node-dev, or with node if the project has been built, from the server directory using:

npx ts-node-dev ./src/dev/createDummyAlbums.ts

or:

node ./dist/dev/createDummyAlbums.js

respectively. Note that development packages need to be installed in order to generate dummy content.

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.