const route = require('@ostro/support/facades/route')
route.get('/greeting', function ({ response }) {
response.send('Hello World');
});
route.domain('admin.domain.com').group(function(route){
route.prefix('users').middleware('admin').name('admin.users.').group(function(route){
route.put('profile','adminController::updateProfile').name('profile.update');
// Route assigned name "admin.users.profile.update" Matches The "admin.domain.com/users/profile" URL and
})
})
route.view('/welcome', 'welcome', {'name' : 'Amar'});
const Controller = require('~/app/http/controllers/controller');
const User = require('~/app/models/user')
class UserController extends Controller {
async show({view,params}) {
view('user.profile', {
'user' : await User.findOrFail(params.id)
});
}
}
module.exports = UserController
route.get('/user/:id', 'userController::show');
let Flight = require('~/app/models/flight'); let flights = await Flight.where('active', 1) .orderBy('name') .take(10) .get();
let flight = await Flight.create({ 'name' : 'London to Paris', });
let user = await DB.table('users').where('name', 'John').first(); console.log(user.email);
/**
* Store a new blog post.
*/
async store({ request }) {
await request.validate({
'title': 'required|unique:posts|max:255',
'body': 'required',
});
// The blog post is valid...
}
const Controller = require('~/app/http/controllers/controller');
class LoginController extends Controller {
async login({ request, validate, auth, redirect }) {
await this.validate(request, {
'email': 'required|email',
'password': 'required'
})
if(await auth.attempt(credentials)){
return redirect.route('admin.dashboard.index');
}
return redirect.withInput().withErrors({email:['Invalid email password']}).back();
}
}
module.exports = LoginController
const Crypt = require('@ostro/support/facades/crypt')
let decrypted = Crypt.decryptString($encryptedValue);
const Hash = require('@ostro/support/facades/hash')
let $hashed = Hash.make('password', {
'rounds' : 12,
});
let $value = await Cache.get('key');
let $value = await Cache.get('key', 'default');
await Cache.put('key', 'value');
await Storage.disk('s3').put('avatars/1', $content);
let $path = await request.file('avatar').storeAs(
'avatars', (await request.user()).id
);
await Storage.put('avatars/1', $content);
await Storage.disk('s3').delete('path/file.jpg');
Log.info('User failed to login.', {'id' : $user.id});
Log.channel('slack').info('Something happened!');
OstroJS is a web application framework with a syntax that is both expressive and beautiful. A web framework gives your application structure and a starting point, allowing you to concentrate on building something wonderful while we sweat the specifics. OstroJS is full featured MVC framework for NodeJS.
Easy and fast development.
Full controller over framework.
Cluster and caching.
Easy to deploy on Any Server.
OstroJS is a "progressive" framework, as we like to call it. That is to say, OstroJS improves along with you. If you're new to web development, Ostro's extensive library of tutorials and instructions can help you get started without feeling stressed.
from OstroJS
Designed Pattern