![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@yamato-daiwa/backend
Advanced tools
Backend framework with build-in TypeScript type safety. Intended to be used in full-stack applications where both client and server part written in TypeScript.
Back-end framework with built-in TypeScript type safety. Clean API, no husk. Intended to be used in full-stack applications where both client and server part written in TypeScript.
npm i @yamato-daiwa/backend -E
:warning: Warning: Below examples has been developed to demonstrate the API of the framework such as easy to understand. For this, the splitting of the code to files and code itself has been minified, but this approach is unfit for the development of the real applications from the viewpoint of architecture.
import { Server, Request, Response, ProtocolDependentDefaultPorts } from "@yamato-daiwa/backend";
import { HTTP_Methods } from "@yamato-daiwa/es-extensions";
Server.initializeAndStart({
IP_Address: "127.0.0.1",
HTTP: { port: ProtocolDependentDefaultPorts.HTTP },
routing: [
{
route: { HTTP_Method: HTTP_Methods.get, pathTemplate: "/" },
async handler(request: Request, response: Response): Promise<void> {
return response.submitWithSuccess({
HTML_Content: "<h1>Hello, world!</h1>"
});
}
}
]
});
See the "Hello, world!" tutorial for the details.
import { Server, Request, Response, ProtocolDependentDefaultPorts } from "@yamato-daiwa/backend";
import { HTTP_Methods } from "@yamato-daiwa/es-extensions";
Server.initializeAndStart({
IP_Address: "127.0.0.1",
HTTP: { port: ProtocolDependentDefaultPorts.HTTP },
HTTPS: {
port: ProtocolDependentDefaultPorts.HTTPS,
SSL_CertificateFileRelativeOrAbsolutePath: "SSL/cert.pem",
SSL_KeyFileRelativeOrAbsolutePath: "SSL/key.pem"
},
routing: [
{
route: { HTTP_Method: HTTP_Methods.get, pathTemplate: "/" },
async handler(_request: Request, response: Response): Promise<void> {
return response.submitWithSuccess({
HTML_Content: "<h1>Hello, world!</h1>"
});
}
}
]
});
See the HTTPS support tutorial for the details.
import ProductController from "./ProductController";
import { Server, Request, Response, ProtocolDependentDefaultPorts } from "@yamato-daiwa/backend";
import { HTTP_Methods } from "@yamato-daiwa/es-extensions";
Server.initializeAndStart({
IP_Address: "127.0.0.1",
HTTP: { port: ProtocolDependentDefaultPorts.HTTP },
routing: [
{
route: { HTTP_Method: HTTP_Methods.get, pathTemplate: "/" },
async handler(_request: Request, response: Response): Promise<void> {
return response.submitWithSuccess({
HTML_Content: "<h1>Top page</h1>"
});
}
},
ProductController
]
});
import { Request, Response, Controller } from "@yamato-daiwa/backend";
import { HTTP_Methods } from "@yamato-daiwa/es-extensions";
export default class ProductController extends Controller {
@Controller.RouteHandler({
HTTP_Method: HTTP_Methods.get,
pathTemplate: "products"
})
public async generateProductsPage(_request: Request, response: Response): Promise<void> {
return response.submitWithSuccess({
HTML_Content: "<h1>Products list</h1>"
});
}
@Controller.RouteHandler({
HTTP_Method: HTTP_Methods.get,
pathTemplate: "products/:ID"
})
public async generateProductProfilePage(request: Request, response: Response): Promise<void> {
return response.submitWithSuccess({
HTML_Content: `<h1>Product with ID: ${request.routePathParameters.ID}</h1>`
});
}
}
See the Routing and controllers tutorial for the details.
import { Request, Response, Controller } from "@yamato-daiwa/backend";
import {
HTTP_Methods,
RawObjectDataProcessor,
convertPotentialStringToNumberIfPossible
} from "@yamato-daiwa/es-extensions";
export default class ProductController extends Controller {
@Controller.RouteHandler({
HTTP_Method: HTTP_Methods.get,
pathTemplate: "products/:ID",
pathParametersProcessing: {
ID: {
preValidationModifications: convertPotentialStringToNumberIfPossible,
type: Number,
required: true,
numbersSet: RawObjectDataProcessor.NumbersSets.nonNegativeInteger
}
}
})
public async generateProductProfilePage(request: Request, response: Response): Promise<void> {
const targetProductID: number = request.getProcessedRoutePathParameters<{ ID: number; }>().ID;
return response.submitWithSuccess({
HTML_Content: `<h1>Product with ID: ${targetProductID}</h1>`
});
}
}
See the Strongly typed route path parameters tutorial for the details.
The query parameters default deserializer is qs with default configuration.
import { Request, Response, Controller, BooleanParameterDefaultPreValidationModifier } from "@yamato-daiwa/backend";
import { HTTP_Methods, RawObjectDataProcessor, convertPotentialStringToNumberIfPossible } from "@yamato-daiwa/es-extensions";
export default class ProductController extends Controller {
@Controller.RouteHandler({
HTTP_Method: HTTP_Methods.get,
pathTemplate: "api/products",
queryParametersProcessing: {
paginationPageNumber: {
preValidationModifications: convertPotentialStringToNumberIfPossible,
type: Number,
required: true,
numbersSet: RawObjectDataProcessor.NumbersSets.naturalNumber
},
itemsCountPerPaginationPage: {
preValidationModifications: convertPotentialStringToNumberIfPossible,
type: Number,
required: true,
numbersSet: RawObjectDataProcessor.NumbersSets.naturalNumber
},
// Valid URL example:
// http://127.0.0.1:80/api/products?forcedFiltering[makerID]=1&paginationPageNumber=1&itemsCountPerPaginationPage=20
forcedFiltering: {
type: Object,
required: false,
properties: {
makerID: {
preValidationModifications: convertPotentialStringToNumberIfPossible,
type: Number,
required: true,
numbersSet: RawObjectDataProcessor.NumbersSets.naturalNumber
}
}
},
consciousFiltering: {
type: Object,
required: false,
properties: {
fullOrPartialProductName: {
type: String,
required: false,
minimalCharactersCount: 2
},
// Valid URL example:
// http://127.0.0.1:80/api/products?consciousFiltering[outOfStock]=true&paginationPageNumber=1&itemsCountPerPaginationPage=20
outOfStock: {
preValidationModifications: BooleanParameterDefaultPreValidationModifier,
type: Boolean,
required: false
},
// Valid URL example:
// http://127.0.0.1:80/api/products?consciousFiltering[categoriesIDs][0]=1&consciousFiltering[categoriesIDs][1]=2&paginationPageNumber=1&itemsCountPerPaginationPage=20
categoriesIDs: {
type: Array,
required: false,
element: {
preValidationModifications: convertPotentialStringToNumberIfPossible,
type: Number,
numbersSet: RawObjectDataProcessor.NumbersSets.naturalNumber
}
}
}
}
}
})
public async retrieveProductsSelection(request: Request, response: Response): Promise<void> {
const {
paginationPageNumber,
itemsCountPerPaginationPage,
forcedFiltering,
consciousFiltering
}: {
paginationPageNumber: number;
itemsCountPerPaginationPage: number;
forcedFiltering?: { makerID: number; };
consciousFiltering?: { fullOrPartialProductName?: number; };
} = request.getProcessedQueryParameters();
console.log(request.URI);
console.log(paginationPageNumber);
console.log(itemsCountPerPaginationPage);
console.log(forcedFiltering);
console.log(consciousFiltering);
// The specific data retrieving is not target of this example
return response.submitWithSuccess({ JSON_Content: [] });
}
}
See the Strongly typed route query parameters tutorial for the details.
import { Server, Request, Response } from "@yamato-daiwa/backend";
import { HTTP_Methods, RawObjectDataProcessor, convertPotentialStringToNumberIfPossible } from "@yamato-daiwa/es-extensions";
import { ObjectDataFilesProcessor } from "@yamato-daiwa/es-extensions-nodejs";
const configFromDotEnvFile: Readonly<{
IP_ADDRESS: string;
HTTP_PORT: number;
}> = ObjectDataFilesProcessor.processFile({
filePath: ".env",
schema: ObjectDataFilesProcessor.SupportedSchemas.DOTENV,
validDataSpecification: {
nameForLogging: "ConfigFromDotenvFile",
subtype: RawObjectDataProcessor.ObjectSubtypes.fixedKeyAndValuePairsObject,
properties: {
IP_ADDRESS: {
type: String,
required: true
},
HTTP_PORT: {
preValidationModifications: convertPotentialStringToNumberIfPossible,
type: Number,
numbersSet: RawObjectDataProcessor.NumbersSets.nonNegativeInteger,
required: true
}
}
}
});
Server.initializeAndStart({
IP_Address: configFromDotEnvFile.IP_ADDRESS,
HTTP: { port: configFromDotEnvFile.HTTP_PORT },
routing: [
{
route: { HTTP_Method: HTTP_Methods.get, pathTemplate: "/" },
async handler(_request: Request, response: Response): Promise<void> {
return response.submitWithSuccess({
HTML_Content: "<h1>Top page</h1>"
});
}
}
]
});
IP_ADDRESS=127.0.0.1
HTTP_PORT=80
See the Dotenv configuration tutorial for the details.
Because the console commands parsing is actual for the console applications, not just for server applications, the ConsoleCommandsParser utility is available in @yamato-daiwa/es-extensions-nodejs package.
import { Server, Request, Response, ProtocolDependentDefaultPorts } from "@yamato-daiwa/backend";
import { HTTP_Methods } from "@yamato-daiwa/es-extensions";
import { ConsoleCommandsParser, ObjectDataFilesProcessor } from "@yamato-daiwa/es-extensions-nodejs";
const configFromConsoleCommand: ConsoleCommandsParser.ParsedCommand<
Readonly<{
IP_Address?: string;
HTTP_Port?: number;
}>
> = ConsoleCommandsParser.parse(
process.argv,
{
applicationName: "Server",
defaultCommand: {
IP_Address: {
type: ConsoleCommandsParser.ParametersTypes.string,
required: false
},
HTTP_Port: {
type: ConsoleCommandsParser.ParametersTypes.number,
numbersSet: RawObjectDataProcessor.NumbersSets.nonNegativeInteger,
required: false
}
}
}
);
Server.initializeAndStart({
IP_Address: configFromConsoleCommand.IP_Address ?? "127.0.0.1",
HTTP: { port: configFromConsoleCommand.HTTP_Port ?? ProtocolDependentDefaultPorts.HTTP },
routing: [
{
route: { HTTP_Method: HTTP_Methods.get, pathTemplate: "/" },
async handler(_request: Request, response: Response): Promise<void> {
return response.submitWithSuccess({
HTML_Content: "<h1>Top page</h1>"
});
}
}
]
});
See the Console Line Interface configuration for the details.
Please take the tutorials in following order.
FAQs
Backend framework with build-in TypeScript type safety. Intended to be used in full-stack applications where both client and server part written in TypeScript.
We found that @yamato-daiwa/backend demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.