Migrating to express.js project

This commit is contained in:
Gregory Ballantine 2022-11-01 22:00:38 -04:00
parent e5c7bdedc1
commit 53e0a557a3
14 changed files with 1045 additions and 1551 deletions

10
.gitignore vendored
View File

@ -1,7 +1,7 @@
# ---> Composer
composer.phar
/vendor/
# ---> NPM modules (mainly for Gulp.js)
# NPM modules (mainly for Gulp.js)
node_modules/
# Compiled CSS and JS assets
public/css/
public/js/

View File

@ -1,4 +1,4 @@
Copyright (c) <year> <owner>
Copyright (c) 2022 Bit Goblin
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

View File

@ -1,4 +0,0 @@
#!/bin/sh
# start a local instance of the app using PHP's built-in webserver
php -S localhost:8080 -t public/ public/index.php

View File

@ -1,24 +0,0 @@
{
"name": "bitgoblin/overseer",
"description": "Self-hosted inventory tracking web app",
"type": "project",
"license": "BSD-2-Clause",
"autoload": {
"psr-4": {
"BitGoblin\\Overseer\\": "src/"
}
},
"authors": [
{
"name": "Gregory Ballantine",
"email": "gballantine@bitgoblin.tech"
}
],
"minimum-stability": "stable",
"require": {
"slim/slim": "^4.10",
"slim/psr7": "^1.5",
"php-di/php-di": "^6.4",
"slim/twig-view": "^3.3"
}
}

1387
composer.lock generated

File diff suppressed because it is too large Load Diff

1068
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,5 +21,9 @@
"gulp": "^4.0.2",
"gulp-sass": "^5.1.0",
"sass": "^1.55.0"
},
"dependencies": {
"express": "^4.18.2",
"twig": "^1.15.4"
}
}

View File

@ -1,5 +0,0 @@
# rewrite rules
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

View File

@ -1 +0,0 @@
body{padding:50px 0 0;background:#d3d3d3}#nav-bar{position:fixed;top:0;left:0;width:100%;height:50px;background:#212121;box-shadow:0 2px 1px rgba(0,0,0,.25)}#nav-bar .nav-bar-left{float:left}#nav-bar ul{list-style:none}#nav-bar ul li{display:inline-block}#nav-bar .nav-link a{color:teal;transition:all 230ms ease-in-out}#nav-bar .nav-link a:hover{color:green}

View File

@ -1,24 +0,0 @@
<?php
// if we're looking for static files in dev, return false so they can be served.
if (PHP_SAPI == 'cli-server') {
$url = parse_url($_SERVER['REQUEST_URI']);
$file = __DIR__ . $url['path'];
// check the file types, only serve standard files
if (preg_match('/\.(?:png|js|jpg|jpeg|gif|css)$/', $file)) {
// does the file exist? If so, return it
if (is_file($file))
return false;
// file does not exist. return a 404
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
printf('"%s" does not exist', $_SERVER['REQUEST_URI']);
return false;
}
}
require_once __DIR__ . '/../src/app.php';
$app->run();

View File

@ -1,19 +0,0 @@
<?php
namespace BitGoblin\Overseer\Controllers;
use Psr\Container\ContainerInterface;
class Controller {
protected $container;
public function __construct(ContainerInterface $container) {
$this->container = $container;
}
public function get(string $name) {
return $this->container->get($name);
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace BitGoblin\Overseer\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;
class HomeController extends Controller {
public function getIndex(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'index.twig');
}
}

View File

@ -1,25 +0,0 @@
<?php
use DI\Container;
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigMiddleware;
require __DIR__ . '/../vendor/autoload.php';
// Create new container object and add our config object to it
$container = new Container();
// Set container to create App with on AppFactory
AppFactory::setContainer($container);
$app = AppFactory::create();
// create Twig instance
$twig = Twig::create('views', ['cache' => false]);
// add Twig-View Middleware
$app->add(TwigMiddleware::create($app, $twig));
// load routes
require_once __DIR__ . '/routes.php';
// app starts in public/index.php

View File

@ -1,7 +0,0 @@
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
// index GET route - this page should welcome the user and direct them to the available actions
$app->get('/', '\\BitGoblin\\Overseer\\Controllers\\HomeController:getIndex')->setName('index');